Excel

TheSmallman.com

an XL ideas Lab

Dashboards VBA
  • Home
  • Dashboards
    • Tips & Tricks
    • Charts
    • Modelling
    • Infographics
    • VBA
  • Shop Dashboards
    • Power Pivot a User Guide
    • Excel Dashboard Course
    • Advanced Dashboard Course
    • Financial Modelling Course
    • Excel VBA Course
  • Blog
  • About
Menu

Excel Dashboards VBA

Street Address
City, State, Zip
Phone Number
an XL ideas Lab

Your Custom Text Here

Excel Dashboards VBA

  • Home
  • Dashboards
  • Excel Tips
    • Tips & Tricks
    • Charts
    • Modelling
    • Infographics
    • VBA
  • Shop Dashboards
  • PowerPivot
    • Power Pivot a User Guide
  • Courses
    • Excel Dashboard Course
    • Advanced Dashboard Course
    • Financial Modelling Course
    • Excel VBA Course
  • Blog
  • About

Excel Merge Sheets to Master

February 23, 2015 Marcus Small
Photo by pine  watt on Unsplash

Photo by pine watt on Unsplash

This article draws on the post from the site which is dedicated to merging worksheets in a workbook into a single master sheet Consolidate Sheets.  This technique can be significantly simplified with a VBA macro.   I have posted this type of reply on forums dozens of times.  Howeve this reply differs just slightly.  The following will consolidate data so the data tables appear side by side in the consolidaiton tab.  So if Sheet 1 appears:

Jan Feb Mar

for the column headers.  While sheet2 has;

Apr May Jun

The consolidation of these two is;

Jan Feb Mar Apr May Jun

In order to do this successfully you need to check the data in Row 1 for the last used column as this may vary.

If there are 4 sheets in your workbook and your data is laid out as follows:

The code when the sheets to consolidate are in blue is as follows.  This can be run from any sheet and assumes the consolidation sheet index number is sheet4.  If you run this code on a fresh worksheet and add a sheet it will run nicely.

Option Explicit

Sub MergeMe() 'Excel VBA to Merge worksheet columns
Dim i As Integer
   For i = 1 To Worksheets.Count - 1
      Sheets(i).[a1].CurrentRegion.Copy Sheet4.Range("IV1").End(xlToLeft)(, 2)
   Next i
End Sub

The above assumes that your data is tabular and starts in A1 with headers. If you wanted to stack your data the following would achieve this.

Option Explicit

Sub MergeMe2() 'Excel VBA to Merge worksheet columns
Dim i As Integer
   For i = 1 To Worksheets.Count - 1
      Sheets(i).[A1].CurrentRegion.Offset(1, 0).Copy Sheet4.[A500000].End(xlUp)(2)
   Next i
End Sub

Be careful as the above assumes 500K rows so if your data is greater than this it won't pick up all of your data. The above also assumes you have a header row ready and waiting in your consolidation sheet.

Hope this coding helps you merge your worksheets.

Tags merge, consolidate, excel, sheets, vba
← Excel VBA to Sort an Array Road Traffic Statistics in Excel →

Featured Posts

Excel Dashboards: Tracking a Crisis

Excel Dashboards: Tracking a Crisis
April 14, 2020

Recent Posts

Populating an Excel Table from a Range of Cells with VBA

Populating an Excel Table from a Range of Cells with VBA June 12, 2025

Fuzzy Distribution with Randbetween

Fuzzy Distribution with Randbetween May 21, 2025

Add Minimum and Maximum for Chart in Cells

Add Minimum and Maximum for Chart in Cells March 12, 2025

Inflation Over Multiple Years in a Single Cell

Inflation Over Multiple Years in a Single Cell January 10, 2025

Hubspot Dashboard

Hubspot Dashboard October 3, 2024

Monthly Dashboard With Supporting Metrics

Monthly Dashboard With Supporting Metrics September 25, 2024

Excel Show Missing Sheet Tabs

Excel Show Missing Sheet Tabs July 29, 2024

Run Macro Overnight Automatically

Run Macro Overnight Automatically June 24, 2024

Split File into Parts and Save to Directory

Split File into Parts and Save to Directory April 20, 2024

Most Popular Author

Most Popular Author December 14, 2023

 

Follow US:

 
 

MarcusSmall@thesmallman.com

 

TheSmallman.com - Making your small systems hum...
© Copyright 2013-2024 theSmallman.com All Rights Reserved.