我有一本工作簿,它刷新数据连接,然后过滤昨天的日期。当只有一行被刷新时,我将得到一个
运行时错误1004。
有时宏可以工作,有时却不能。每天运行一次。
Sub Get_VRIDs()
Dim i As Integer
Sheets("Cancels").Select
i = 1
With Range("E2")
If .Cells(1, 1).Value = "" Then
Else
Range(.Cells(1, 1), .End(xlDown)).Copy
Destination:=Sheets("Metric").Range("a6")
x = x + 1
End If
End With
Sheets("Adhoc").Select
i = 1
With Range("C2")
If .Cells(1, 1).Value = "" Then
Else
Range(.Cells(1, 1), .End(xlDown)).Copy Destination:=Sheets("Metric").Range("a94")
x = x + 1
End If
End With
Sheets("Direct Tender").Select
i = 1
With Range("B2")
If .Cells(1, 1).Value = "" Then
Else
Range(.Cells(1, 1), .End(xlDown)).Copy Destination:=Sheets("Metric").Range("a132")
x = x + 1
Sheets("Metric").Activate
End If
End With
Sheet1.Activate
Range("B6").Select
Selection.Copy
Range("A6:A90").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWindow.SmallScroll Down:=48
Range("B60").Select
Selection.Copy
Range("A94:A128").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWindow.SmallScroll Down:=24
Range("B90").Select
Selection.Copy
Range("A132:A200").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWindow.SmallScroll Down:=-108
Range("A7").Select
Call Hide_Rows
End Sub
此行发生错误:
Range(.Cells(1, 1), .End(xlDown)).Copy Destination:=Sheets("Metric").Range("a94")