Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining data from multiple tabs in excel

Status
Not open for further replies.

laina222

Technical User
Sep 7, 2001
172
US
I have an excel file that was given to me with dozens of tabs. Each tab has the same column headings with different data. I need to get all this data onto one tab. Is there a less tedious method than copying and pasting?

Thanks
 

Here is a VBA routine that can do the job:

It assumes your data begin with column names in row 1 and have data in the other rows with no blank rows. If any of those assumptions are wrong, please post back with more details about exactly how your data are formatted.
Code:
Sub CombineData()
Dim sNewSheet As Worksheet
Dim sSheet As Worksheet
Dim rData As Range

  With Sheets(1)
    Intersect(.UsedRange, .Rows(1)).Copy
    Set sNewSheet = Sheets.Add
  End With
  With sNewSheet
    .Name = "Composite"
    .PasteSpecial
  End With
  Application.CutCopyMode = False
       
  For Each sSheet In Sheets
    If sSheet.Name <> sNewSheet.Name Then
      With sSheet.Range("A1").CurrentRegion.Offset(1, 0)
        .Copy sNewSheet.Range("A65536").End(xlUp).Offset(1, 0)
      End With
    End If
  Next
End Sub
Alt-F11 to open the VBA editor.
Insert / Module (from the VBA editor menu)
Copy and paste the code.
F5 to run.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top