I have a function that I use to send a string to the windows clipboard:
Sub TextToClipboard(ByVal Text As String)
With CreateObject(\"new:{1C3B4210-F441-1
Win10 broke MSForms.DataObject; that's why the approach that works on Win7/32 or Win7/64 don't work now. Thank you, Khang Huynh, for a simple and elegant mod to the original macro.
I suggest a couple of tweaks:
Option Explicit
Private Sub CopyCellContents()
' dimension our vars
Dim objData As New DataObject
' set the contents of the active cell as our data object, removing extraneous spaces and linebreaks
with objData
.SetText Trim(ActiveCell.Text)
' write it to the Clipboard
.PutInClipboard
' just for fun
Application.StatusBar = .GetText
End With
' clean up memory by not leaving object handles open
Set objData = Nothing
End Sub