VBA新手在这里。我正在努力编写脚本以将多个(〜250个)工作表中特定单元格的数据提取到主工作表中。例: 我希望脚本从名为Cand 4,Cand 5,Cand 6等的工作表中的单元格B3:C3,E4,B15:C20中提取数据。
我想我的循环部分工作正常,但是缺少其他东西。救命! 任何人都对脚本的外观有所猜测吗?谢谢!
答案 0 :(得分:0)
这就是我要怎么做。
VBA代码:
Option Explicit
Sub Copy_Paste_Sheets()
Dim i
Dim Sheet_List As Range
Dim Sheet_List_String As String
For i = 1 To 250 'number of sheets
Set Sheet_List = Range("Sheets_List")
Sheet_List_String = Sheet_List.Cells(i, 1)
'Range 1
Sheets(Sheet_List_String).Range("B3:C3").Copy Sheets("Master").Cells(i,1) 'Destination 1 (i=row, 1=column)
Application.CutCopyMode = False
'Range 2
Sheets(Sheet_List_String).Range("E4").Copy Sheets("Master").Cells(i,1) 'Destination 2 (i=row, 1=column)
Application.CutCopyMode = False
'Range 3
Sheets(Sheet_List_String).Range("B15:C20").Copy Sheets("Master").Cells(i,1) 'Destination 3 (i=row, 1=column)
Application.CutCopyMode = False
Next i
End Sub