[英]vba excel : runtime error 1004 method range of object _global failed
[英]“runtime error 1004 method range of object _global failed” VBA error
请协助解决错误:
对象_global的运行时错误1004方法范围失败
我在这个vba中收到了。
在此之前,我还有大约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
谢谢!
尝试这样:
If FndRw = vbNullString then Stop
Worksheets("19_01").Range("AM" & FndRw & ":AM" & lastRw1).ClearContents
并始终确保您引用正确的工作表并指定变量的类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.