简体   繁体   English

“对象_global的运行时错误1004方法范围失败” VBA错误

[英]“runtime error 1004 method range of object _global failed” VBA error

Please help with the error: 请协助解决错误:

runtime error 1004 method range of object _global failed 对象_global的运行时错误1004方法范围失败

That I recieve in this vba. 我在这个vba中收到了。

I have around 10 more VBAs before this one, none of them return an error, but this one (they are identical, only page numbers a different): 在此之前,我还有大约10个VBA,但没有一个返回错误,但是这个(它们是相同的,只是页码不同):

Sub actualizare()
Dim lastRw1, lastRw2, nxtRw, m
Dim StartRow, x
Dim StartDate As String
Dim FndRw As String

lastRw1 = Sheets(11).Range("B" & Rows.Count).End(xlUp).Row

StartDate = Range("908!A21").Value

For StartRow = 1 To lastRw1
If Range("19_01!B" & StartRow).Value = StartDate Then

FndRw = StartRow
Exit For
End If
Next

***Range("19_01!AM" & FndRw & ":AM" & lastRw1).ClearContents***

lastRw2 = Sheets(15).Range("A" & Rows.Count).End(xlUp).Row

For nxtRw = 1 To lastRw2

With Sheets(11).Range("B2000:B" & lastRw1)

Set m = .Find(Sheets(15).Range("A" & nxtRw), lookat:=xlWhole)

If Not m Is Nothing Then
Sheets(15).Range("B" & nxtRw).Copy _
Sheets(11).Range("AM" & m.Row)

End If
End With
Next
End Sub

Thank you! 谢谢!

Try like this: 尝试这样:

If FndRw = vbNullString then Stop
Worksheets("19_01").Range("AM" & FndRw & ":AM" & lastRw1).ClearContents

And always make sure that you refer to the correct worksheet and specify the type of your variables. 并始终确保您引用正确的工作表并指定变量的类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM