+ Reply to Thread
Results 1 to 6 of 6

Macro to consolidate individual sheets into single sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    11-22-2019
    Location
    London
    MS-Off Ver
    Office 365 Business
    Posts
    2

    Question Macro to consolidate individual sheets into single sheet

    Hello,

    I have a set of identical excel worksheets that are completed by various team members. All these sheets have the same number of columns but varying number of rows.

    I would like to create a macro that will consolidate all the data from those individual sheets into a single sheet.

    I have found various online tutorials but they all end up consolidating the individual sheets into a single workbook but as separate worksheets within the same workbook (i.e. they are not consolidated into a single worksheet).

    I'd appreciate any help
    Thanks

  2. #2
    Forum Contributor
    Join Date
    12-22-2017
    Location
    INDIA
    MS-Off Ver
    EXCEL 2007
    Posts
    106

    Re: Macro to consolidate individual sheets into single sheet

    Upload the sample file
    If solved press * add reputation

  3. #3
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,633

    Re: Macro to consolidate individual sheets into single sheet

    Hi and welcome
    various solutions at https://www.rondebruin.nl/win/section3.htm
    or an add-in at
    https://www.rondebruin.nl/win/addins/rdbmerge.htm

  4. #4
    Registered User
    Join Date
    11-22-2019
    Location
    London
    MS-Off Ver
    Office 365 Business
    Posts
    2

    Re: Macro to consolidate individual sheets into single sheet

    Hi,

    Thank you for replying.

    I can't find a way of uploading a copy of the file I would like to consolidate (multiple copies of the same template).

    Basically, I will have multiple copies of a template from various sources. It will contain 23 columns of data.

    What I am trying to do is to consolidate all my copies into a single sheet (I've managed to bring them all together but in separate tabs).

    Each of the templates will have a different number of rows so the macro should copy all rows with data (note that some fields may be blank in the workbook, but the First Column will always hold a value (Col. A) ).

    I appreciate your assistance.

    Regards,
    CA

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,633

    Re: Macro to consolidate individual sheets into single sheet

    [QUOTE=aerobee;5233702]Hi,



    I can't find a way of uploading a copy of the file I would like to consolidate (multiple copies of the same template).[\QUOTE]

    I thought the yellow banner was explicit enough..
    Have you tried the solutions suggested in post #3?

  6. #6
    Forum Contributor
    Join Date
    12-22-2017
    Location
    INDIA
    MS-Off Ver
    EXCEL 2007
    Posts
    106

    Re: Macro to consolidate individual sheets into single sheet

    This code is to merge all the workbooks in the new worksheet "Master"

    Sub mergeWorksheetsALL()
        Dim wrk As Workbook
        Dim sht As Worksheet
        Dim trg As Worksheet
        Dim rng As Range
        Dim colCount As Integer
         
        Set wrk = ActiveWorkbook
         
        For Each sht In wrk.Worksheets
            If sht.name = "Master" Then
                MsgBox "There is a worksheet called as 'Master'." & vbCrLf & _
                "Please remove or rename this worksheet since 'Master' would be" & _
                "the name of the result worksheet of this process.", vbOKOnly + vbExclamation, "Error"
                Exit Sub
            End If
        Next sht
         
        
        Application.ScreenUpdating = False
         
       
        Set trg = wrk.Worksheets.add(After:=wrk.Worksheets(wrk.Worksheets.Count))
         
        trg.name = "Master"
        
        Set sht = wrk.Worksheets(1)
        colCount = sht.Cells(1, 255).End(xlToLeft).Column
        
        With trg.Cells(1, 1).Resize(1, colCount)
            .Value = sht.Cells(1, 1).Resize(1, colCount).Value
            .Font.Bold = True
        End With
         
        
        For Each sht In wrk.Worksheets
            
            If sht.index = wrk.Worksheets.Count Then
                Exit For
            End If
            
            Set rng = sht.Range(sht.Cells(2, 1), sht.Cells(65536, 1).End(xlUp).Resize(, colCount))
            trg.Cells(65536, 1).End(xlUp).Offset(1).Resize(rng.Rows.Count, rng.Columns.Count).Value = rng.Value
        Next sht
         
        trg.Columns.AutoFit
            
        Application.ScreenUpdating = True
    End Sub
    ------------------
    if solved press * add reputation

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to consolidate from 2 Sheets to a Result Sheet
    By prkhan56 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-11-2017, 05:59 AM
  2. Macro to Consolidate Data from 3 Sheets to a Result Sheet
    By rehana402003 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-17-2016, 07:08 AM
  3. Replies: 20
    Last Post: 06-20-2013, 09:04 AM
  4. Replies: 0
    Last Post: 09-05-2012, 11:57 AM
  5. Need macro to consolidate data from different sheets to single sheet
    By sekharyadav in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-18-2012, 03:20 AM
  6. Macro to consolidate many workbooks to a single worbook/sheet
    By Greed in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-05-2012, 02:49 PM
  7. adapt macro to select individual sheet rather than all sheets
    By mania112 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-14-2009, 10:18 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1