0% found this document useful (0 votes)
3 views

Using VBA

The document provides instructions on consolidating data from multiple Excel sheets into a single sheet using VBA, manual copy-paste, or formulas. It details a VBA macro that creates a 'Consolidated' sheet, copies data from each sheet, and updates automatically when rerun. Additionally, it mentions a manual method for copying data and highlights that this method does not update automatically.

Uploaded by

t.santhoshkumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Using VBA

The document provides instructions on consolidating data from multiple Excel sheets into a single sheet using VBA, manual copy-paste, or formulas. It details a VBA macro that creates a 'Consolidated' sheet, copies data from each sheet, and updates automatically when rerun. Additionally, it mentions a manual method for copying data and highlights that this method does not update automatically.

Uploaded by

t.santhoshkumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

.

Using VBA (Visual Basic for Applications):

If you’re comfortable with VBA, you can write a macro to consolidate the data. Here’s an
example of how you can do it:

1. Press ALT + F11 to open the VBA editor.


2. Go to Insert > Module to create a new module.
3. Paste the following VBA code into the module:

vba
Copy code
Sub ConsolidateSheets()
Dim ws As Worksheet
Dim wsConsolidate As Worksheet
Dim lastRow As Long
Dim consolidateRow As Long

' Add a new sheet for consolidation


On Error Resume Next
Set wsConsolidate = ThisWorkbook.Sheets("Consolidated")
On Error GoTo 0

If wsConsolidate Is Nothing Then


Set wsConsolidate = ThisWorkbook.Sheets.Add
wsConsolidate.Name = "Consolidated"
End If

' Clear existing data


wsConsolidate.Cells.Clear

consolidateRow = 1

' Loop through each sheet


For Each ws In ThisWorkbook.Sheets
If ws.Name <> wsConsolidate.Name Then
' Copy data from each sheet
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
ws.Range("A1:Z" & lastRow).Copy
Destination:=wsConsolidate.Cells(consolidateRow, 1)
consolidateRow =
wsConsolidate.Cells(wsConsolidate.Rows.Count, 1).End(xlUp).Row + 1
End If
Next ws

' Autofit columns


wsConsolidate.Columns.AutoFit
End Sub

4. Run the macro:


o Press F5 in the VBA editor or go back to Excel and run the macro from
Developer > Macros.
5. To keep the data updated automatically, you’ll need to rerun the macro each
time changes are made.

3. Using Manual Copy-Paste:


If you don’t want to use Power Query or VBA, you can manually copy and paste the data
from each sheet into a single sheet. However, this method doesn’t automatically update and
requires manual intervention.

1. Open the first sheet, select the data, and copy it.
2. Go to the consolidated sheet, and paste the data.
3. Repeat for each sheet, pasting data below the existing data in the consolidated
sheet.

4. Using Formulas (for static data):


Sub ConsolidateSheets()

Dim ws As Worksheet

Dim wsConsolidate As Worksheet

Dim lastRow As Long

Dim consolidateRow As Long

' Add a new sheet for consolidation

On Error Resume Next

Set wsConsolidate = ThisWorkbook.Sheets("Consolidated")

On Error GoTo 0

If wsConsolidate Is Nothing Then

Set wsConsolidate = ThisWorkbook.Sheets.Add

wsConsolidate.Name = "Consolidated"

End If

' Clear existing data

wsConsolidate.Cells.Clear

consolidateRow = 1

' Loop through each sheet

For Each ws In ThisWorkbook.Sheets

If ws.Name <> wsConsolidate.Name Then

' Copy data from each sheet

lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row

ws.Range("A1:Z" & lastRow).Copy Destination:=wsConsolidate.Cells(consolidateRow, 1)

consolidateRow = wsConsolidate.Cells(wsConsolidate.Rows.Count, 1).End(xlUp).Row + 1

End If
Next ws

' Autofit columns

wsConsolidate.Columns.AutoFit

End Sub

https://chatgpt.com/

i have 15 sheets of excel and its have same type of columns heading and i want to see all data in
single sheet as consolidated data and whenever data is entering in any sheet , it should appear in
consolidated sheet

You might also like