Forum Discussion
Lindsy
Nov 29, 2022Copper Contributor
VBA to compile multiple differently named worksheets
Hi, I have code compiled from a few sources with the aim to compile 230 individual spreadsheets in to one long one. (I have tried a query and as the tabs are all named differently this does not s...
HansVogelaar
Nov 29, 2022MVP
Line #47 in your code is
lrow2 = wsTarget.Cells(Rows.Count, 1).End(xlUp).Row + 1 'change the "1" to the column # of the beginning of the data set (defult is column A)
This calculates the last used row in column A (column #1) of the target sheet and adds 1.
If column A is empty, this will result in lrow2 = 2 each time.
You'll need to specify a column that is guaranteed to be populated. Let's say that column D (column #4) is always filled. Change line #47 to
lrow2 = wsTarget.Cells(Rows.Count, 4).End(xlUp).Row + 1
Lindsy
Nov 29, 2022Copper Contributor
That seem to break the code, the code loops open and close but nothing is pasted after the first loop. This may be being made more difficult by the fact on the MI it is coping and pasting Ctrl A highlights 50,000 rows most of which are blank, and this is the same for all 230 workbooks I am trying to append.