Automatic Summing of Adjacent Columns Based On Manually Entered Range

moonwater

New Member
Joined
Aug 18, 2023
Messages
1
Office Version
  1. 365
Platform
  1. MacOS
Hey All, I was wondering if I some help trying to make my life easier.

I'm trying to calculate very roughly some wastage on a production run but the definition of a production run can be a bit loose and isn't defined by the product code for example. So if I know that Product Codes AAA and BBB share the same widgets but are just packed in different packaging.

I would like to be able to just manually select one row of cells which might seem completely arbitrary, for example Rows 5-8, and for the cells in Columns C, D and E to be automatically summed for me.

Is there any way for that to be done?

Screen Shot 2023-08-18 at 3.26.38 pm.png
 

Attachments

  • Screen Shot 2023-08-18 at 3.05.11 pm.png
    Screen Shot 2023-08-18 at 3.05.11 pm.png
    70.7 KB · Views: 7
  • Screen Shot 2023-08-18 at 3.11.07 pm.png
    Screen Shot 2023-08-18 at 3.11.07 pm.png
    78.5 KB · Views: 6
  • Screen Shot 2023-08-18 at 3.15.50 pm.png
    Screen Shot 2023-08-18 at 3.15.50 pm.png
    100.6 KB · Views: 7
  • Screen Shot 2023-08-18 at 3.19.09 pm.png
    Screen Shot 2023-08-18 at 3.19.09 pm.png
    109.1 KB · Views: 5

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Put the macro below in the sheet module.
Where do you want to put the totals? The code below shows totals in a message box.
You need to select complete and contiguous rows.
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Selection.Columns.Count = Columns.Count Then
    With WorksheetFunction
        MsgBox "Selection Totals :" & Chr(13) & Chr(13) _
        & "Column C " & .Sum(Intersect(Selection, [C:C])) & Chr(13) _
        & "Column D " & .Sum(Intersect(Selection, [D:D])) & Chr(13) _
        & "Column E " & .Sum(Intersect(Selection, [E:E])) & Chr(13)
    End With
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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