I'm trying to figure out how to copy multiple rows without a line break from Excel to a text file via VBA. I found a code on this website from Peter (link) that helped me a lot but it only works for me when copying one cell (F1 for example):
Private Sub CommandButton3_Click()
Dim DataObj As New MSForms.DataObject
DataObj.SetText ActiveSheet.Range("F1")
DataObj.PutInClipboard
End Sub
I tried to modify the code above for copying multiple cells as follows:
Private Sub CommandButton3_Click()
Dim DataObj As New MSForms.DataObject
DataObj.SetText ActiveSheet.Range("F1:F10")
DataObj.PutInClipboard
End Sub
But I'm getting an error - Run-time error '13': type mismatch. Any idea how to do this?