multi-sheet adder

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
Someone on here wrote this for me and I haven't been able to get back in touch for a few questions.

Basically this is supposed to add the figures in Cell N10 from all sheets named "Noon" + Index # (i.e. Noon, Noon2, Noon3, Noon4 etc) as well as from R17 from the "Arrival" Sheet. The total for this number goes into cell R10 on the "Arrival" (Active) Sheet. The number of "Noon" sheets is a varying number (there's a macro that generates new ones as necessary) and sometimes there are zero "Noon" sheets. There is ALWAYS an arrival sheet and it's always the last sheet in the workbook. There are 4 sheets in the beginning of the workbook (developer, notes, ports, voyage specifics) before the first possible noon or the arrival- we don't add figures from any of these first four pages.

I'm not exactly sure how to set this up to add as I want it to. Maybe someone can explain or tweak if necessary.

Code:
Private Sub TotalNoonSheetAdder()'Has the ability to add all values from multiple noons and a single cell selection


WS_Count = ActiveWorkbook.Worksheets.Count
Eqat = "="
nooncnt = 0
        For i = 1 To WS_Count
            Tname = ActiveWorkbook.Worksheets(i).Name
            If Left(Tname, 4) - "Noon" Then
             Eqat = Eqat & "+" & "Noon" & "!N12"
             nooncnt = nooncnt + 1
            End If
        Next i
 If nooncnt > 0 Then
  ActiveCell.Formula = Eqat & "+R10"
 End If
End Sub
 
Last edited:

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,216,143
Messages
6,129,113
Members
449,487
Latest member
Jeffsk

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