A
Andrew Stedman
Hi all,
I have the following macro that sums any cells that I select:
Sub CopySum()
Dim MyDataObj As New DataObject
Dim str As String
str = Selection.Address
MyDataObj.SetText "=sum(" & str & ")"
MyDataObj.PutInClipboard
End Sub
The macro works fine but I would like to be able to paste the result into
another worksheet. At the moment if I say select cells A1 and B1, the result
would be "=sum($A$1,$B$1)" when I hit paste. When I go to the next worksheet
and paste, the resulting formula obviously doesn¹t work as the cell
references do not include the original sheet name.
Ive tried adding ActiveSheet.Name to the macro but I couldn¹t work out how
to add the sheet name before each cell I selected.
Any help greatly appreciated.
Andrew.
I have the following macro that sums any cells that I select:
Sub CopySum()
Dim MyDataObj As New DataObject
Dim str As String
str = Selection.Address
MyDataObj.SetText "=sum(" & str & ")"
MyDataObj.PutInClipboard
End Sub
The macro works fine but I would like to be able to paste the result into
another worksheet. At the moment if I say select cells A1 and B1, the result
would be "=sum($A$1,$B$1)" when I hit paste. When I go to the next worksheet
and paste, the resulting formula obviously doesn¹t work as the cell
references do not include the original sheet name.
Ive tried adding ActiveSheet.Name to the macro but I couldn¹t work out how
to add the sheet name before each cell I selected.
Any help greatly appreciated.
Andrew.