• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Can't Combine Data from Multiple Sheets into a Single Sheet Using VBA

fahadferoz

Member
Hi All

I have a Workbook with three data Sheets that have the same headers (but different row numbers on each). I want to combine this data onto the “Import” sheet automatically once I update the three sheets (which has the exact same headers too) using VBA.

I have tried inserting codes for it. But can't figure out the problem. The workbook is attached herewith. Please help me solve this.

Fahad.
 

Attachments

  • Workbook1.xlsb
    48.8 KB · Views: 3
Is this how you wanted?
Code:
Sub test()
    Dim ws As Worksheet
    Sheets("import").Cells(1).CurrentRegion.Offset(1).Clear
    For Each ws In Worksheets
        If ws.Name <> "Import" Then
            With ws.Cells(1).CurrentRegion
                .AutoFilter 3, "<>"
                .Offset(1).Resize(.Rows.Count - 2).Copy _
                Sheets("import").Range("a" & Rows.Count).End(xlUp)(2)
                .AutoFilter
            End With
        End If
    Next
End Sub
 
The data does not automatically get updated.
Also Is it possible to organize the date in date wise in the "Import" file?

Thanks for the effort.
 
Dear Jindon

Thanks for helping me. It is almost there. Please help me out.
 

Attachments

  • rsz_code_requirements_in_vba.jpg
    rsz_code_requirements_in_vba.jpg
    223.9 KB · Views: 5
To Import sheet code module
Code:
Private Sub Worksheet_Activate()
    Dim ws As Worksheet
    Application.ScreenUpdating = False
    Cells(1).CurrentRegion.Offset(1).Clear
    For Each ws In Worksheets
        If ws.Name <> "Import" Then
            With ws.Cells(1).CurrentRegion
                .AutoFilter 3, "<>"
                .Offset(1).Resize(.Rows.Count - 2).Copy Range("a" & Rows.Count).End(xlUp)(2)
                .AutoFilter
            End With
        End If
    Next
    Cells(1).CurrentRegion.Sort Cells(1, 2), , , , , , , True
    Application.ScreenUpdating = True
End Sub
 
Thanks Again. But it did not do it. Please have a look at the picture where I showed the exact coding and the result.

Thanks a lot for your support though.
 

Attachments

  • rsz_hi.jpg
    rsz_hi.jpg
    218.7 KB · Views: 10
So you don't understand what I said...
 

Attachments

  • Workbook1 with code.xlsb
    37 KB · Views: 6
Back
Top