Consolidating 4 seperate worksheets

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
I have 4 worksheets where the structure is exactly the same except the figures differ

The worksheet have text and values in columns A to S. I need to write VBA code that will combine the data and show the descritions in a consolidated woorksheet.

Your assistance will be most appreciated


Howard
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
please elaborate? do you mean you want to include the sheet name where the data came from?
 
Upvote 0
I want to include the sheet names from where the data came from

For eg if I have if I have 4 worksheets for eg Sheet1 + Sheet2 +Sheet3 +Sheet4 with the following columns and data, I would like to combine these into an new worksheet "sheet5"

Account No. Description Current Month Closing Bal


Your assistance will be most appreciated


Howard
 
Upvote 0
not sure about the exact layout of your spreadsheet. this code will put sheet name in columnT of summary sheet. copied data from individual sheet starting from row 2;
Code:
Sub consol()
Dim i, ii As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheets("summary").Delete
Sheets.Add after:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = "summary"
For i = 1 To 4
    For ii = 2 To Sheets(i).Range("a" & Rows.Count).End(xlUp).Row
        Sheets(i).Cells(ii, "t").Value = Sheets(i).Name
    Next
    
        Sheets(i).Range("a2:t1000").Copy
            With Sheets("summary").Range("a" & Rows.Count).End(xlUp).Offset(1)
                .PasteSpecial xlValues
            End With
    Sheets(i).Columns("t").ClearContents
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
 
Upvote 0
Hi Agihcam

Thanks for your help.

It would be appreciated if you would provide me with your email address, so that I can attach my files if I need some further help

Howard
 
Upvote 0
Hi Agicam

A little while ago you provided me with code to consolidate 4 seperate worsheets (see code below)

I have just tested the code and the following comes up as a compile error

    For ii = 2 To Sheets(i).Range("a" & Rows.Count).End(xlUp).Row


Please test and correct

If I had 4 seperate workfiles and I wanted to combine these all into a new workfile named Consolidation Tax Schedules , how would the code look.

Look forward to hearing from you.

Howard
 
Upvote 0
is it 4 separate files or 4 separate sheets in a single workbook. My understanding from your original post is that, you have 4 worksheets.
 
Upvote 0
Hi Agihcam

At present I need to consolidate 4 seperate worksheets.

I also have 4 seperate workbooks where A need to consolidate all the data (there are several worksheets on each workbok) , that needs to be consolidated into a new workbook, to be named say "Consolidated Tax"

Your assistance will be most appreciated

Regards


Howard
 
Upvote 0
Hi Agihcam

At present I need to consolidate 4 seperate worksheets.
I haven't seen any error with mine.
I have Sheet1,Sheet2,Sheet3,Sheet4 with data in a single workbook. after running the code I've got a consolidated data in new sheet called summary.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top