我正在尝试运行一个循环,它之前在另一个工作簿上工作,但是当我尝试将其转移到新的工作簿时,我不断弹出对象的方法范围。
有什么想法吗?
以下是代码:
Option Explicit
Sub MapLoop2()
Dim varRng As Variant
Dim lngR As Long
Dim lngS As Long
Dim rngSrc As Range
Dim rngDest As Range
On Error GoTo lblErr
Application.ScreenUpdating = False
Set rngDest = Sheet3.Range("A2")
rngDest.CurrentRegion.ClearContents
varRng = shtMap.Range("rngStartP").CurrentRegion
For lngR = 2 To UBound(varRng, 1) ''4
If varRng(lngR, 1) <> "" Then
For lngS = 1 To UBound(varRng, 2) ''13
Sheet25.Range("rngTopCell").Offset(lngS, 1) = varRng(lngR, lngS)
Next
Module1.ProductGen "ZZZZZZZZZZZZZZZZZZ Importer_" & varRng(lngR, 1) & ".xls"
Set rngSrc = Sheet26.Range("A2").CurrentRegion
If rngSrc.Rows.Count > 0 Then
Application.Calculate
rngSrc.Copy
rngDest.PasteSpecial xlPasteValues
Set rngDest = rngDest.Offset(rngSrc.Rows.Count)
End If
End If
Next
Application.Goto shtMap.Range("rngStartP")
shtMap.Range("rngStartP").Select
Application.Goto rngDest.Cells(1, 1)
rngDest.Cells(1, 1).Select
Call pSaveAsOutput
MsgBox "Done", vbInformation
Application.ScreenUpdating = True
lblErr:
If Err.Number <> 0 Then
MsgBox "Error Number: " & Err.Number & vbCrLf & "Description: " & Err.Description
End If
End Sub