Stormrider2230
New Member
- Joined
- Dec 3, 2021
- Messages
- 5
- Office Version
- 2016
- Platform
- Windows
Hello.
How to copy data from all worksheets in a workbook, into a new single worksheet, creating a new worksheet named "Combined" but not adding them below into same columns (last used row +1), but to the side. First data from the first copied worksheet into "Combined" shoud go into A1, then next worksheet to the last used column +1 to the right side, and looping across all ather worksheets and pasting data like mentioned....to the last used column +1.
There can be two or more worksheets, they can have different names, length of rows and columns also varies, so generic formula should be used.
I tried to adjust some code from the example below but no luck with adjusting Selection.Copy Destination.
Will appreciate any help.
Thanks and regards,
Rob
How to copy data from all worksheets in a workbook, into a new single worksheet, creating a new worksheet named "Combined" but not adding them below into same columns (last used row +1), but to the side. First data from the first copied worksheet into "Combined" shoud go into A1, then next worksheet to the last used column +1 to the right side, and looping across all ather worksheets and pasting data like mentioned....to the last used column +1.
There can be two or more worksheets, they can have different names, length of rows and columns also varies, so generic formula should be used.
I tried to adjust some code from the example below but no luck with adjusting Selection.Copy Destination.
VBA Code:
Dim Sun As Integer
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Combined"
Sheets(2).Activate
Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")
For Sun = 2 To Sheets.Count
Sheets(Sun).Activate
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
Next
End sub
Will appreciate any help.
Thanks and regards,
Rob