im trying to put some data in the clipboard with VBA
The code goes like:
Sub PasaraformatoSQLDATA()
Dim clipboard As MSForms.DataObject
Dim ArraySelc As Variant
Dim SourceRange As Range
Dim Lenr As Long
Dim ArrayString As Variant
Set SourceRange = Selection.CurrentRegion
ArraySelct = SourceRange.Value
Lenr = UBound(ArraySelct)
For i = 1 To Lenr
ArraySelct(i, 1) = "'" & ArraySelct(i, 1) & "'"
Next i
'Condicion zero
ArrayString = ArraySelct(1, 1)
'Rellenar el resto
For p = 2 To Lenr
ArrayString = ArrayString & "," & ArraySelct(p, 1)
Next p
clipboard.SetText ArrayString
clipboard.PutInClipboard
End Sub
What this code is suppouse to do is to take any given info in a Range, take it and put into a single string with a format 'data,' & 'data2,' & ...
But I'm having problems with the last part that is putting my info into the clipboard. I get an
error 424, an object is required.
Can you help me out? I think the error might be on the ArrayString that actually is an Array and should be an String, but I'm just guessing.
Thanks in advance for any help!
Best Regards