View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Adding a selection of values and storing result in a variable

Here is a little macro that uses Z100 as a "helper" cell:

Sub simka()
With Range("Z100")
.Value = Application.WorksheetFunction.Sum(Selection)
.Copy
End With
End Sub

You can assign the macro to a button or give it a shortcut key.

After running the macro, click on some other cell and CNTRL-v or
Edit Paste

will depost the sum.
--
Gary''s Student - gsnu200804


"Simka" wrote:

This may have been asked before but - I regularly need to find the sum of a
(random) selection of values on a worksheet by selecting the range by and/or
holding down the SPACEBAR or CTRL key and then viewing the sum of the values
on the status bar. Idealy, I would like to press a button to start a macro to
add up all the values that have been selected and store the result in a
variable so that then this value can be pasted elsewhere. Any suggestions on
the coding?