SOLVED

Moving data from one excel tab to another

Copper Contributor

Hi,

 

Is there an easier way of moving data from one excel tab to another other than just copying and pasting. I've got data in 70 tabs and want all that data in 1 tab.

 

Thanks

4 Replies

@notaexcelexpert 

Do you want to move the data from ALL sheets be combined, or from some of the sheets in the workbook?

Should the data from Sheet2 be moved below the data from Sheet1 etc.?

Are there header rows that should be repeated or not?

Hi,

The data from sheet2 should be moved below data from sheet1 etc

Thanks
best response confirmed by notaexcelexpert (Copper Contributor)
Solution

@notaexcelexpert  Here is an example of a macro that can help you combine data from multiple sheets into one sheet.

-------

Sub CombineSheets()
Dim ws As Worksheet
Dim wsNew As Worksheet
Dim i As Long

' Create a new worksheet
Set wsNew = ThisWorkbook.Sheets.Add(Before:=ThisWorkbook.Sheets(1))
wsNew.Name = "Combined Data"

' Loop through all worksheets in the workbook
For Each ws In ThisWorkbook.Worksheets
' Skip the new worksheet
If ws.Name <> wsNew.Name Then
' Find the last row with data in the new worksheet
i = wsNew.Cells(wsNew.Rows.Count, 1).End(xlUp).Row + 1

' Copy the data from the current worksheet to the new worksheet
ws.UsedRange.Copy wsNew.Cells(i, 1)
End If
Next ws
End Sub

-----

This macro creates a new worksheet called “Combined Data” and then loops through all the worksheets in the workbook. For each worksheet, it finds the last row with data in the new worksheet and then copies the data from the current worksheet to the new worksheet.

To use this macro, you can press Alt + F11 to open the Visual Basic editor, then right-click on your workbook name in the Project window and select Insert > Module. Paste the code into the new module and then press F5 or click on the Run button to run the macro.

I hope this helps

@H2O  Thanks

1 best response

Accepted Solutions
best response confirmed by notaexcelexpert (Copper Contributor)
Solution

@notaexcelexpert  Here is an example of a macro that can help you combine data from multiple sheets into one sheet.

-------

Sub CombineSheets()
Dim ws As Worksheet
Dim wsNew As Worksheet
Dim i As Long

' Create a new worksheet
Set wsNew = ThisWorkbook.Sheets.Add(Before:=ThisWorkbook.Sheets(1))
wsNew.Name = "Combined Data"

' Loop through all worksheets in the workbook
For Each ws In ThisWorkbook.Worksheets
' Skip the new worksheet
If ws.Name <> wsNew.Name Then
' Find the last row with data in the new worksheet
i = wsNew.Cells(wsNew.Rows.Count, 1).End(xlUp).Row + 1

' Copy the data from the current worksheet to the new worksheet
ws.UsedRange.Copy wsNew.Cells(i, 1)
End If
Next ws
End Sub

-----

This macro creates a new worksheet called “Combined Data” and then loops through all the worksheets in the workbook. For each worksheet, it finds the last row with data in the new worksheet and then copies the data from the current worksheet to the new worksheet.

To use this macro, you can press Alt + F11 to open the Visual Basic editor, then right-click on your workbook name in the Project window and select Insert > Module. Paste the code into the new module and then press F5 or click on the Run button to run the macro.

I hope this helps

View solution in original post