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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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