vba 中对象所需错误

vba 中对象所需错误

我正在尝试运行以下宏以在多个选定的工作表中输入文本。但我收到运行时错误“424”需要对象

Sub CL_Numbering()
Dim shts As Worksheet
i = 1
For Each shts In ActiveWindow.SelectedSheets
  shts.Range("M3").Value = "EDRC-E-EM-FT-" & worsheetfunction.Text(i, "00") & " R0"
  i = i + 1
Next shts

End Sub

答案1

修改为:

Sub CL_Numbering()
Dim shts As Worksheet
dim i as long
i = 1
For Each shts In ActiveWindow.SelectedSheets
  shts.Range("M3").Value = "EDRC-E-EM-FT-" & Application.WorksheetFunction.Text(i, "00") & " R0"
  i = i + 1
Next shts


End Sub

相关内容