Hello,

I'm trying to finish a VBA macro so that I can copy/paste the sum of the selected visible cells.


The code below:

Sub mySum()
Dim MyDataObj As New DataObject
MyDataObj.SetText Application.Sum(Selection)
MyDataObj.PutInClipboard
End Sub

However, this currently will sum ALL cells in the selected range, even filtered ones. What should I add to sum only the visible selected cells?

Thanks!