It's basically a follow-on from these statements:
Sub Simka1()
'This routine adds the values of selected cells and
'places the result in cell A5000 then copies the value to clipboard.
With Range("A5000")
.Value = Application.WorksheetFunction.Sum(Selection)
.Copy
End With
End Sub
and
Sub Simka2()
'This routine adds the values of selected cells and
'places the result in the variable 'SumOfRange'.
Dim SumOfRange As Double
SumOfRange = 0
SumOfRange = Application.WorksheetFunction.Sum(Selection) 'Add the Range
Debug.Print SumOfRange 'Check result in Immediate window
End Sub
Where routine Simka1 places the value into cell A5000 and then copies the
value into the clipboard, this is the long run makes the worksheet size
(file) much bigger.
Routine Simka2 does much the same thing except it places the value in the
variable SumOfRange so that I could then use a different routine to place
that value later.
I want a mixture of the two. I want routine Simka2 but then place the value
into the clipboard ready for pasting elsewhere. So I am after something like:
Sub Simka2()
Dim SumOfRange As Double
SumOfRange = 0
SumOfRange = Application.WorksheetFunction.Sum(Selection) 'Add the Range
Value in Clipboard = SumOfRange
Debug.Print SumOfRange 'Check result in Immediate window
End Sub
"Wigi" wrote:
> What do you intend to do with the variable?
>
> Wouldn't there be better methods to use, then?
>
> --
> Wigi
> http://www.wimgielis.be = Excel/VBA, soccer and music
>
>
> "Simka" wrote:
>
> > Hi everyone,
> >
> > My head has gone blank. I am trying to copy the contents of a variable into
> > the clipboard.
> >
> > ie:
> > value in clipboard = MyVariable
> >
> > Can someone please remind me?
> >