Copy data from 4 identical sheets to single sheet

glynn1969

Board Regular
Joined
Nov 24, 2018
Messages
80
Office Version
  1. 365
Platform
  1. Windows
Hello (i have simplified my query a little)

I have 4 sheets with data in rows, on each sheet in column A I have an identifier eg "X".

My want is to have a VBA which will copy data from sheet 1, all rows with the X identifier to sheet 5 - with no spaces between rows.

Then to look at sheet 2 and again move all rows with the X identifier to sheet 5 directly underneath the sheet1 data - again leaving no rows.....repeat for sheet 3 and sheet4.


So sheet 5 will have all data from sheets 1-4 where the X identifier was identified into a single worksheet with no spaces between the rows.

Here's hoping one of you clever people can help.

Thank you
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Are there other sheets in the book?

If not, try:

Code:
Sub Test()


Dim rownum As Long
Dim lastrow As Long


rownum = 2


For Each Sheet In ThisWorkbook.Sheets
If Sheet.Name <> "Sheet5" Then
Sheet.Select
Set sht = ActiveSheet
lastrow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
For Each cell In Sheet.Range("A1:A" & lastrow)
    If cell.Value = "X" Then
        rownum2 = cell.Row
        Rows(rownum2).Copy Sheets("Sheet5").Rows(rownum)
        rownum = rownum + 1
    End If
Next
End If
Next Sheet


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,521
Messages
6,120,018
Members
448,937
Latest member
BeerMan23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top