I have my values summarized in Excel by this code:
Sub AutoSum()
Dim Sumcalc As Integer
Range("E" & Cells(Rows.Count, "E").End(xlUp).Row + 1).Value = _
WorksheetFunction.Sum(Range("E2:E" & Cells(Rows.Count, "A").End(xlUp).Row))
MsgBox (Application.Sum(Range("E2:E" & Cells(Rows.Count, "A").End(xlUp).Row)))
End Sub
and they appear in Msgbox fine. The problem is, that I can't copy this result from there at all.
I tried to change my Msgbox to something like userform with the field
Selectable Text in VBA Message Box
https://www.thespreadsheetguru.com/blog/2015/1/13/how-to-use-vba-code-to-copy-text-to-the-clipboard
and my code finally looks like this:
Sub AutoSum()
Dim Sumcalc As Integer
Range("E" & Cells(Rows.Count, "E").End(xlUp).Row + 1).Value = _
WorksheetFunction.Sum(Range("E2:E" & Cells(Rows.Count, "A").End(xlUp).Row))
Sumcalc = Application.Sum(Range("E2:E" & Cells(Rows.Count, "A").End(xlUp).Row))
Clipboard =.GetData(Sumcalc)
MsgBox ("Copy to clipboard","Copy Text", Sumcalc)
End Sub
but I am getting an error:
Invalid or unqualified reference for .GetData
In the Msgbox I can't pass a defined variable, just a text value.
How could I copy my Msgbox result to the clipboard or at least making it selectable?