0
我的宏的目的是讓用戶在他們的模型中選擇他們想檢查硬編碼的範圍。宏然後在彙總表上打印工作表,單元格地址和硬代碼的值。如果您僅從一張紙上進行選擇,該宏目前效果很好;但是,如果將選擇擴展到多個工作表,宏將創建多個工作表,而不是僅打算執行一個工作表。預先感謝您的時間和幫助VBA - 防止添加多張表格
Set RngCon = Selection.SpecialCells(xlCellTypeConstants, xlNumbers)
Set SumWS = Worksheets.Add
Username = InputBox("Please create a name for the output sheet (i.e. Whs Industry Hard Codes)")
SumWS.Name = Username
x = 1
SumWS.Cells(x, 1) = "Worksheet"
SumWS.Cells(x, 2) = "Address"
SumWS.Cells(x, 3) = "Value"
For Each c In RngCon
x = x + 1
SumWS.Cells(x, 1) = c.Worksheet.Name
SumWS.Cells(x, 2) = c.Address(False, False)
SumWS.Cells(x, 3) = c.Value
Next c