Forum Discussion
PatDools
Oct 15, 2025Brass Contributor
Not including all columns when consolidating multiple Excel onto one tab?
Hello - I am running the following VBA code to write all rows/columns from multiple worksheets (in the same workbook) onto a 'consolidated' worksheet in that same workbook. My columns on all workshee...
m_tarler
Oct 15, 2025Bronze Contributor
I think you problem is this line:
' Define the range to copy
Set copyRange = ws.Range("A1", ws.Cells(lastRow, ws.Columns.Count).End(xlToLeft))
it starts at the right most column then goes to the the left but if that last row doesn't have all the data it won't be the full number of columns
make sure the row you are on has all the columns you need (e.g. the header row) something like:
' Define the range to copy
Set copyRange = ws.Range("A1", ws.Cells(1, ws.Columns.Count).End(xlToLeft))