![vba 中对象所需错误](https://linux22.com/image/1631768/vba%20%E4%B8%AD%E5%AF%B9%E8%B1%A1%E6%89%80%E9%9C%80%E9%94%99%E8%AF%AF.png)
我正在尝试运行以下宏以在多个选定的工作表中输入文本。但我收到运行时错误“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