Merging Excel Worksheets into existing Worksheet

Sorry if this is a duplicate, but all I want to do is append my existing worksheets into an existing worksheet in the same workbook to create one long worksheet. The number of columns in each worksheet differ. All solutions I’ve seen are in VBA, incorrect or I’m unable to correctly paste after the last row used in my target worksheet. The code I’ve tried is

foreach ($ws in $wb.Worksheets){ $ws.cells.copy() $lastRow = $ws.UsedRange.rows.count + 1 $ws.Range("A" + $lastrow).Activate() $ws.Paste() } 

but i get the error that “You can’t paste this here because the Copy area and paste area aren’t the same size.” Any one know how to solve my problem? This is driving me insane. Or if you know how to merge these column wise, I’ll take that too

submitted by /u/curious_student123
[link] [comments]

Leave a Reply