I am doing a data pull that consolidates the data from multiple workbooks into a single workbook. My current code works as advertised; however, I would like to make the code more flexible by having it refer to specific cells in a spreadsheet on what and where to pull my data. I am having a problem with how to reference multiple workbooks with a single statement.
So, in regards to:
Where I can get "wsVar" to refer to a single, specific worksheet with no problem, such as:
But now, how do you go about rewriting "wsVar" where it refers to multiple worksheets as referenced in a column range of cells? Such as wsExtract.Range("A2:A8"), which in the spreadsheet it would look like:
A1 Worksheet Name
A2 Apple
A3 Banana
A4 Orange
A5 Pear
A6 Grape
A7 Mango
A8 Pineapple
I don't want to have to go into the code every time there is a change with these names. It would be nice if I could just update the column of worksheet names.
Any ideas?
So, in regards to:
VBA Code:
'DATA PULL
With wsConsolidate_2
.Range(.Cells(LRT2 + 1, 2), wsConsolidate_2.Cells(LRT2 + LRwsVar - 4, 20)).Value = wsVar.Range("A5:S" & LRwsVar).Value
End With
Where I can get "wsVar" to refer to a single, specific worksheet with no problem, such as:
VBA Code:
Dim wsVar as Worksheet
Set wsVar = Sheets("Apple")
But now, how do you go about rewriting "wsVar" where it refers to multiple worksheets as referenced in a column range of cells? Such as wsExtract.Range("A2:A8"), which in the spreadsheet it would look like:
A1 Worksheet Name
A2 Apple
A3 Banana
A4 Orange
A5 Pear
A6 Grape
A7 Mango
A8 Pineapple
I don't want to have to go into the code every time there is a change with these names. It would be nice if I could just update the column of worksheet names.
Any ideas?