Excel高亮选中行列
Sub 复制() 'sheet1中的代码复制到激活工作表中的工作表对象中 Dim wb As Workbook, vb1, vb2, str$ Application.ScreenUpdating = False For Each wb In Workbooks If wb.Name ThisWorkbook.Name Then wb.Close True Next Set wb = Workbooks.Open(ThisWorkbook.Path & "\测试.xlsm") Set vb1 = wb.VBProject.VBComponents("Sheet1") Set vb2 = ThisWorkbook.VBProject.VBComponents("Sheet1") str = vb2.CodeModule.Lines(1, vb2.CodeModule.CountOfLines) vb1.CodeModule.DeleteLines 1, vb1.CodeModule. CountOfLines vb1.CodeModule.AddFromString str Workbooks("动态高亮.xlsm").Close False Application.ScreenUpdating = True '复制完之后,关闭这个工作表 End Sub Sub 删除() '将激活工作表中的工作表对象中的代码删除 Dim wb As Workbook Application.ScreenUpdating = False For Each wb In Workbooks If wb.Name ThisWorkbook.Name Then wb.Close True Next Set wb = Workbooks.Open(ThisWorkbook.Path & "\测试.xlsm") With wb.VBProject.VBComponents("Sheet1") .CodeModule.DeleteLines 1, .CodeModule.CountOfLines End With wb.Sheets(1).Cells.FormatConditions.Delete Workbooks("动态高亮.xlsm").Close SaveChanges:=False Application.ScreenUpdating = False '删除之后,关闭这个工作表 End Sub CountOfLines vb1.CodeModule.AddFromString str Workbooks("动态高亮.xlsm").Close False Application.ScreenUpdating = True '复制完之后,关闭这个工作表 End Sub Sub 删除() '将激活工作表中的工作表对象中的代码删除 Dim wb As Workbook Application.ScreenUpdating = False For Each wb In Workbooks If wb.Name ThisWorkbook.Name Then wb.Close True Next Set wb = Workbooks.Open(ThisWorkbook.Path & "\测试.xlsm") With wb.VBProject.VBComponents("Sheet1") .CodeModule.DeleteLines 1, .CodeModule.CountOfLines End With wb.Sheets(1).Cells.FormatConditions.Delete Workbooks("动态高亮.xlsm").Close SaveChanges:=False Application.ScreenUpdating = False '删除之后,关闭这个工作表 End Sub
文件列表
Excel动态高亮.zip
(预估有个3文件)
动态高亮.xlsm
17KB
103428c20z6c63ru1tt1o9.jpg
122KB
100328i52hp6ypy614yvuw.jpg
96KB
暂无评论