Dont Call me Betty
New Member
- Joined
- Sep 29, 2023
- Messages
- 19
- Office Version
- 365
- Platform
- Windows
Below code does not reliably paste Values only, different formatting gets in.
Tried different approaches, like recording a macro while doing Paste Values.
Nothing works consistently to ONLY paste Values, to match the cell formatting, font, etc.
Tried different approaches, like recording a macro while doing Paste Values.
Nothing works consistently to ONLY paste Values, to match the cell formatting, font, etc.
VBA Code:
Sub Paste()
'Tools -> References -> Microsoft Forms 2.0 Object Library
'or you will get a "Compile error: user-defined type not defined"
Dim DataObj As New MSForms.DataObject
Dim s As String
DataObj.GetFromClipboard
s = DataObj.GetText
'Debug.Print S 'print code in the Intermediate box in the Macro editor
Target.Value = s
End Sub