View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
WhytheQ WhytheQ is offline
external usenet poster
 
Posts: 246
Default Adding a selection of values and storing result in a variable

You could loop though the cells collection, of the selection in the
activesheet - whilst looping each cells value could be added to a
variable.
The above should be pretty easy: let me know if you are struggling.

Then to get the variable onto the clipboard some code like the
following might help:

Set DataObj = New MSForms.DataObject
DataObj.SetText myVariableAmount
DataObj.PutInClipboard

....you'll need to add a reference to the following library for the
above to work: Microsoft Forms 2.0 Object Library

Hope this helps
Jason.




On 11 Sep, 13:32, 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?