Add Totals Column on multiple sheets

jayped

Board Regular
Joined
Mar 20, 2019
Messages
54
Good day,

I have a workbook containing multiple sheets and a 'Summary' sheet. I have a column in the Summary sheet named 'Balance as Per Schedule' and I want to sum the amounts in the 'Total' columns on each sheet by using the ID No as the criteria.

Basically there is a column for 'Total' on each sheet and ID No on each of those sheets as well. I want the total of those Totals on the Summary Sheet for every ID number.

The ID Numbers are in column B from row 4 in each sheet. The "Balance as Per Schedule' column is column Q beginning row 4 as well.

The other sheets are named 'Credit Card', 'Travel Advance', etc, for example:

'Credit Card'
NameID No.Total
John1001250.00
Luke1002460.00

<tbody>
</tbody>
There are many columns between ID No. and Total

'Travel Advance'
NameID No.Total
John1001500.00
Luke1002700.00


<tbody>
</tbody>


The Summary Sheet will look like this:
NameID No.B/FJulAugSepOctNovDecJanFebMarAprMayJunTotalBalance as Per ScheduleVariance
John1001750.00
Luke10021160.00

<tbody>
</tbody>



Thank you!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi@jayped,

Basically there is a column for 'Total' on each sheet


You didn't mention which column, in the macro I put column "C", change it if necessary.

Try this


Code:
Sub Totals_multiple_sheets()
  Dim sh As Worksheet, su As Worksheet, i As Long, f As Range, lr As Long
  Set su = Sheets("[COLOR=#0000ff]Summary[/COLOR]")
  For Each sh In Sheets
    If sh.Name <> su.Name Then
      For i = 4 To sh.Range("B" & Rows.Count).End(xlUp).Row
        Set f = su.Range("B:B").Find(sh.Range("B" & i).Value, , xlValues, xlWhole)
        If Not f Is Nothing Then
          su.Range("Q" & f.Row).Value = su.Range("Q" & f.Row).Value + sh.Range("[COLOR=#ff0000]C[/COLOR]" & i).Value
        Else
          lr = su.Range("B" & Rows.Count).End(xlUp).Row + 1
          su.Range("A" & lr).Value = sh.Range("A" & i).Value
          su.Range("B" & lr).Value = sh.Range("B" & i).Value
          su.Range("Q" & lr).Value = sh.Range("[COLOR=#ff0000]C[/COLOR]" & i).Value
        End If
      Next
    End If
  Next
End Sub
 
Upvote 0
Thank you for your reply.

What if the Total column in each sheet is not in the same column?
 
Upvote 0
There should be some reference to search for the column.
 
Upvote 0
What should I change the "C" to if the column letter for totals will vary across the workbook?
 
Upvote 0
What should I change the "C" to if the column letter for totals will vary across the workbook?

I am not understanding what you need.

You have this:

'Credit Card'
NameID No.Total
John1001250.00
Luke1002460.00

<tbody>
</tbody>


In which column you have the column "Total"

You never mentioned in which column you have Total, I assumed it was column "C". But if it is not the "C" and it is the "M", then change in the macro the letter "C" for an "M".
I don't know what the column is, because I'm not seeing your sheets.

After updating the column in the macro, you try the macro and tell me.
If the macro works for the original requirement you put comments. If you later want to make a change, I will gladly review it.
 
Upvote 0
Ok. In the sheet below 'Total' is column DG

'Credit Card'
NameID No.Total
John1001250.00
Luke1002460.00

<tbody>
</tbody>

There are many columns between ID No. and Total


And 'Total' below is column DK
'Travel Advance'
NameID No.Total
John1001500.00
Luke1002700.00

<tbody>
</tbody>


And there is another sheet and 'Total' is in column BL.

How would I get around this?
 
Upvote 0
Ok. In the sheet below 'Total' is column DG

And 'Total' below is column DK

And there is another sheet and 'Total' is in column BL.

How would I get around this?

As I mentioned in post #4 , there should be a reference or a pattern in all the sheets to know in which column the total is. In fact, it could be the word "Total", if in the header row there is only one "Total" word on each sheet, that is our reference.
I hope that the header row is only in a specific row. Well, you must also tell me which line the header is on.
 
Upvote 0

Forum statistics

Threads
1,213,513
Messages
6,114,064
Members
448,545
Latest member
kj9

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