Greetings,
I have a fairly simple copy and paste subroutine to bring some numbers into an excel spreadsheet. The Sub inserts a row on each sheet, copies from another sheet, and then pastes back into the initial sheet. I have about 30 sheets from which to do this with and am confused as to how to structure the code to do this. I would like the array values to be paired by their position so that 'name1' and '123' run on the same loop and 'name2' and '124' run on the same loop.
Any ideas? Is an array the right tool to use or is there something more effective?
Thanks!
I have a fairly simple copy and paste subroutine to bring some numbers into an excel spreadsheet. The Sub inserts a row on each sheet, copies from another sheet, and then pastes back into the initial sheet. I have about 30 sheets from which to do this with and am confused as to how to structure the code to do this. I would like the array values to be paired by their position so that 'name1' and '123' run on the same loop and 'name2' and '124' run on the same loop.
Code:
Dim A As Variant
Dim B as Variant
Dim C as Variant
Dim D as Variant
B = Array("name1","name2"...etc)
D = Array("123","124"...etc)
For Each A in B
Windows("bigbook.xlsx").Activate
Sheets(A).Select
Range("A2").Select
Selection.EntireRow.Insert
Next A
For Each B In D
Windows(B & ".xls").Activate
Range("A2:B2").Select
Selection.Copy
Windows("bigbook.xlsx").Activate
Sheets(A).Select
Range("A2").Select
ActiveSheet.Paste
Next A
Any ideas? Is an array the right tool to use or is there something more effective?
Thanks!