Macro - Sum highlighted cells and copy

Houstonking

New Member
Joined
Jul 12, 2016
Messages
41
Hello, I need a macro that will sum any cells I selected, copy the sum value of it, and remember it so I can paste it wherever I want.

Please help.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
VBA Code:
Sub SumToClipboard()
    'Must enable Forms Library: Checkmark Tools > References > Microsoft Forms 2.0 Object Library
    Dim obj As New DataObject, n As Double
    n = Application.Sum(Selection)
    obj.SetText n
    obj.PutInClipboard
End Sub
 
Upvote 0
Please update your account details to show what version of Excel you are using.
If you are using MS 365 do you really need a macro for that ?
When you select your values the Sum (Average, Count and some other calculations you can display) will show in the Status bar.
A "Single Click" on the value in the Status bar will copy it into the clipboard. Ctrl+V to paste it wherever you want to place the result.
 
Upvote 0

Forum statistics

Threads
1,215,111
Messages
6,123,155
Members
449,098
Latest member
Doanvanhieu

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