我正在尝试从另一个工作簿中的工作表中提取数据,但它无法正常工作。我没有在代码中出现错误,但是它不是从我想要的工作表中提取数据,而是在打开工作簿时打开任何工作表。我在某处读到不需要激活工作表,所以我不确定以下代码有什么问题:
Dim prfile1 As String
Dim prfile2 As String
Dim filepath As String
Dim checktotal As Integer
Dim checkrng As Range
Dim emunber As String
prfile1 = Worksheets("setup").Range("B10").Value
prfile2 = Worksheets("setup").Range("B7").Value
filepath = Worksheets("setup").Range("e10").Value
emunber = Worksheets("ReprintOld").Range("V3").Value
Workbooks.Open filepath & prfile2
Windows(prfile2).Activate
Sheets(emunber).Activate
checktotal = Workbooks(prfile2).Worksheets(emunber).Range("AE1")
With Workbooks(prfile2).Worksheets(emunber)
Set checkrng = Range(Range("U5"), Range("U" & 4 + checktotal).End(xlDown))
End With
Windows(prfile1).Activate
MsgBox emunber
MsgBox checktotal
MsgBox checkrng.Address