|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub 复制() 'sheet1中的代码复制到激活工作表中的工作表对象中
- Dim wb As Workbook, vb1, vb2, str$
- Application.ScreenUpdating = False
- For Each wb In Workbooks
- If wb.Name <> ThisWorkbook.Name Then
- Set vb2 = ThisWorkbook.VBProject.VBComponents("Sheet1")
- str = vb2.CodeModule.Lines(1, vb2.CodeModule.CountOfLines)
- For Each vb1 In wb.VBProject.VBComponents
- If vb1.Name Like "Sheet*" Then
- vb1.CodeModule.DeleteLines 1, vb1.CodeModule.CountOfLines
- vb1.CodeModule.AddFromString str
- End If
- Next
- End If
- Next
- Workbooks("动态高亮.xlsm").Close False
- Application.ScreenUpdating = True
- '复制完之后,关闭这个工作表
- End Sub
- Sub 删除() '将激活工作表中的工作表对象中的代码删除
- Dim wb As Workbook, sht As Worksheet
- Application.ScreenUpdating = False
- For Each wb In Workbooks
- If wb.Name <> ThisWorkbook.Name Then
- For Each vb In wb.VBProject.VBComponents
- If vb.Name Like "Sheet*" Then vb.CodeModule.DeleteLines 1, vb.CodeModule.CountOfLines
- Next
- For Each sht In wb.Worksheets
- sht.Cells.FormatConditions.Delete
- Next
- End If
- Next
- Workbooks("动态高亮.xlsm").Close SaveChanges:=False
- Application.ScreenUpdating = False
- '删除之后,关闭这个工作表
- End Sub
复制代码 |
评分
-
2
查看全部评分
-
|