Hi,
I will be importing a number of CSV files into a workbook and this will create individual worksheets, generic name sheet1, sheet2........., I will be pulling the same 4 items of data from each sheet into 'Totals' sheet.
My question is, I have the Total amount of sheets counted and stored as 'shts', Is it possible to have an incremental variable / string linked to the sheet name so that i can retrieve the data from each sheet as the total amount of imports/sheets may vary?
Code So far,
Dim shts As String
shts = ThisWorkbook.Sheets.Count
' This is a check count
' Cells(3, 3) = shts
Sheets("Totals").Range("A2").Value = Sheets("sheet2").Range("A2").Value
Sheets("Totals").Range("B2").Value = Sheets("sheet2").Range("B2").Value
Sheets("Totals").Range("C2").Value = Sheets("sheet2").Range("I8").Value
Sheets("Totals").Range("D2").Value = Sheets("sheet2").Range("I7").Value
End Sub
Can the '2' in the Sheet name be replaced by a variable name?
Thanks In Advance.
o/
I will be importing a number of CSV files into a workbook and this will create individual worksheets, generic name sheet1, sheet2........., I will be pulling the same 4 items of data from each sheet into 'Totals' sheet.
My question is, I have the Total amount of sheets counted and stored as 'shts', Is it possible to have an incremental variable / string linked to the sheet name so that i can retrieve the data from each sheet as the total amount of imports/sheets may vary?
Code So far,
Dim shts As String
shts = ThisWorkbook.Sheets.Count
' This is a check count
' Cells(3, 3) = shts
Sheets("Totals").Range("A2").Value = Sheets("sheet2").Range("A2").Value
Sheets("Totals").Range("B2").Value = Sheets("sheet2").Range("B2").Value
Sheets("Totals").Range("C2").Value = Sheets("sheet2").Range("I8").Value
Sheets("Totals").Range("D2").Value = Sheets("sheet2").Range("I7").Value
End Sub
Can the '2' in the Sheet name be replaced by a variable name?
Thanks In Advance.
o/