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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
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,768
Messages
6,126,783
Members
449,336
Latest member
p17tootie

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