Consolidating worksheets into one

后端 未结 2 478
长发绾君心
长发绾君心 2020-11-29 12:43

I have a few excel worksheets in the style of

Organization 1


Name Occupation

Chris - contracter

Jane - employee


Organiz

相关标签:
2条回答
  • 2020-11-29 13:26

    Kindly use RDBMerge add-in which will combine the data from different worksheet and create a master sheet for you. Please see the below link for more details.

    http://duggisjobstechnicalstuff.blogspot.in/2013/03/how-to-merge-all-excel-worksheets-with.html

    Download RDBMerge

    0 讨论(0)
  • 2020-11-29 13:33

    I don't know if i understand your problem, but this could help:

    Sub MergeAll()
    Dim r As Long, ws As Worksheet, rAll As Long, wsAll As Worksheet
    Dim i As Long
    Worksheets.Add After:=Worksheets(Worksheets.Count)
    ActiveSheet.name = "All"
    Set wsAll = ActiveSheet
    rAll = 2
    For Each ws In Worksheets
        If ws.name <> "All" Then
            r = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
            For i = 1 To r
                wsAll.Cells(rAll, 1) = ws.name
                wsAll.Cells(rAll, 2) = ws.Cells(i, 1)
                wsAll.Cells(rAll, 3) = ws.Cells(i, 2)
                rAll = rAll + 1
            Next i
        End If
    Next ws
    End Sub
    

    I guessed, that there is one Excel file with multiple sheets. Each sheet represents one organization. So the makro will run through each sheets (except Sheet with name "All") and write the data of the sheets to "All". I hope that is what you need.

    0 讨论(0)
提交回复
热议问题