所以你们其中一个人在另一个问题中发布了这段代码: 昏暗的wkbkorigin作为工作簿 昏暗的起源表作为工作表 Dim destsheet As Worksheet Dim ResultRow As Long Dim Fname As String Dim RngDest作为范围 Dim Ws As Worksheet
Set destsheet = ThisWorkbook.Worksheets("Sheet1")
Set RngDest = destsheet.Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0).EntireRow
Fname = Dir(ThisWorkbook.Path & "/*.xlsm")
'loop through each file in folder (excluding this one)
Do While Fname <> "" And Fname <> ThisWorkbook.Name
Set wkbkorigin = Workbooks.Open(ThisWorkbook.Path & "/" & Fname)
Set originsheet = wkbkorigin.Worksheets("1st")
For Each ws In ThisWorkbook.Worksheets
With RngDest
.Cells(1).Value = originsheet.Range("D3").Value
.Cells(2).Value = originsheet.Range("E9").Value
.Cells(3).Value = originsheet.Range("D22").Value
'.Cells(4).Value = originsheet.Range("E11").Value
'.Cells(5).Value = originsheet.Range("F27").Value
End With
wkbkorigin.Close SaveChanges:=False 'close current file
Set RngDest = RngDest.Offset(1, 0)
Fname = Dir() 'get next file
Loop
End Sub
问题是我只能查看每个工作簿中的第一个工作表并复制该数据。我试图通过查看每个工作簿中的每个工作表并从相同的单元格复制数据。无论如何要做到这一点。谢谢