我正在应的数据传送到名为“皮斯托亚”不同的片的宏并且是这样的码:对象变量或与块变量未设置91 VBA
Sub SetCounter(ByVal counter As Double, ByVal product As String)
Dim ws As Worksheet
On Error Resume Next
Sheets("pistoia").Activate
Set ws = ActiveWorkbook.Sheets("pistoia")
On Error GoTo 0
If ws Is Nothing Then
MsgBox "pistoia sheet not found"
Else
If ws.Name = ActiveWorkbook.ActiveSheet.Name Then
Dim index_destRow As Integer, index_destColumn As Integer, search_product As Range
Rows(2).Find(What:="Nome commerciale", LookAt:=xlWhole, LookIn:=xlValues).Offset(2).Select
Else
MsgBox "pistoia sheet found but is inactive"
End If
End If
End Sub
误差在提高该行:“行(2)。找到(什么:=”Nome commerciale“,LookAt:= xlWhole,LookIn:= xlValues).Offset(2)。选择”,我认为错误是由于激活新的工作表,因为在前面的宏中,“在起始页上”我在导致错误的行中执行相同的操作。有什么建议么?
在'行(2)'前加'ws.'。将对象分配给对象可确保该调用作用于所需的指定对象。另一件事是确保“Nome commerciale”存在于你正在寻找的地方。 –
我试过用ws。但是没有任何变化......并且是的,我已经检查了第2行 –
如果你在命令前添加'debug.print'并将'.Select'改为'.Value'。错误是否持续?或者它是否在即时窗口中返回一个值? –