OK so I have my import working sweet, for the 1 worksheet, which is just a single row of data, this cycles through multiple workbooks that are located in a specific folder and collects all the data from each one required.
However, I have a second worksheet, on each workbook, all formatted the same, including on the book im importing to. This worksheet, has multiple rows of data and could be anything from 1 to 30 rows.
I can get it to import the single row of data, within the vba that does the above part that is working. This is the code I currently have for this section where I need it to read all rows that have data and import them into my database workbook
wbSource and ID are declared earlier in the main code, and work as expected. But how do I wrap this section in a loop or get it to read all rows of data to import?
However, I have a second worksheet, on each workbook, all formatted the same, including on the book im importing to. This worksheet, has multiple rows of data and could be anything from 1 to 30 rows.
I can get it to import the single row of data, within the vba that does the above part that is working. This is the code I currently have for this section where I need it to read all rows that have data and import them into my database workbook
VBA Code:
Workbooks("database.xlsm").Activate
Sheets(2).Activate
Sheets(2).Range("B1").Select
'get next blank cell
While ActiveCell.Value <> ""
ActiveCell.Offset(1, -1).Range("B1").Select
Wend
'input results
rowTarget = ActiveCell.Row
Set wsSource = wbSource.Worksheets(7) 'EDIT IF NECESSARY
Set wsTarget = Sheets(2)
With wsTarget
.Range("B" & rowTarget).Value = ID
.Range("C" & rowTarget).Value = wsSource.Range("C2").Value
.Range("D" & rowTarget).Value = wsSource.Range("D2").Value
.Range("E" & rowTarget).Value = wsSource.Range("E2").Value
.Range("F" & rowTarget).Value = wsSource.Range("F2").Value
End With
wbSource and ID are declared earlier in the main code, and work as expected. But how do I wrap this section in a loop or get it to read all rows of data to import?