文章预览
学习Excel技术,关注微信公众号: excelperfect 标签: VBA 在编写代码时,通常需要声明工作表变量、设置一些环境变量状态等,例如声明工作表变量: Dim wsSHEET1 as
Worksheet 然后给其赋值: Set wsSHEET1 =
wb.Sheets("Sheet1") 下面的代码可以自动生成这些通用代码: Sub CreateWorksheetGenCoding() Dim ws As Worksheet Dim wsName As String Dim sName As String Dim sNames As String Dim blnSheetsWanted As Boolean c00 = "Dim ws" c01 = " as Worksheet" c02 = "Set ws" c03 = " = wb.Sheets(""" c04 = " = Nothing" sNames = "/" For i = 1 To ActiveWorkbook.Sheets.Count Set ws = ActiveWorkbook.Sheets(i) wsName = ws.Name ws.Activate sName = "" Do sName = Trim(UCase(Application.InputBox( _ IIf(ws.Visible = xlSheetHidden, "隐藏的 - " & vbCr & vbCr, IIf(ws.Visible = xlSheetVeryHidden, "深度隐藏的 - " & vbCr & vbCr
………………………………