My goal is to build a singular datafile by copying and pasting data from multiple workbooks. The multiple workbooks have the exact same file structure, so ranges to copy are the same across each. Data in source workbooks are located in four different tabs (same tab names across multiple source workbooks), the ranges to be copied from are the same in each tab. The data are in columns in the source workbooks, and (preferably) need to be transpose pasted into the destination workbook.
Column (j) Range to copy from: 2-200 (or, B-GR) Row (i) range to copy from: 7-81
Destination of (j7:j81) is Qi:CMi
So - B7:B81 should be transpose pasted into Q2:CM2, C7:C81 should transpose paste into Q3:CM3, and so on.
I am trying to find the magical code that will iterate through the four tabs in the ActiveWorkbook, and copy and paste in the correct range. The code I'm using seems to ignore the array and copy and paste from worksheets outside of the array. The macro is also pasting well beyond the specified range. I'm over my head here and would love some guidance.
Sub CopyArray2()
Application.ScreenUpdating = False
Dim sh As Worksheet
Dim i As Long, j As Long
For Each sh In ActiveWorkbook.Sheets(Array("Oct-Dec Parent-Caregiver Survey", _
"Jan-Mar Parent-Caregiver Survey", _
"Apr-Jun Parent-Caregiver Survey", _
"Jul-Sep Parent-Caregiver Survey"))
Rem: i = rows, j=columns
i = 2
j = 2
With sh
For j = 2 To 200
Range(j & "7" & ":" & j & "81").Copy
ThisWorkbook.Sheets("Parent").Range("Q" & i & ":" & "CM" & i).PasteSpecial _
Paste:=xlPasteValues, Transpose:=True
Next j
End With
Next sh
End Sub
Bookmarks