most
Board Regular
- Joined
- Feb 22, 2011
- Messages
- 106
- Office Version
- 365
- 2019
- Platform
- Windows
- Mobile
If a select three cells with Ctrl and then Ctrl-C and Ctrl-V into a new cell I get the result as you can below, "b d f".
But if I paste it into a text file, I get "b c d e f"!? How come?
Is it possible to convert the clipboard data "correctly" with macro?
I'm using the clipboard data for this macro, which updates the auto filter with data from the clipboard.
I need to use clipboard since I some times copy data from other sources.
But if I paste it into a text file, I get "b c d e f"!? How come?
Is it possible to convert the clipboard data "correctly" with macro?
I'm using the clipboard data for this macro, which updates the auto filter with data from the clipboard.
I need to use clipboard since I some times copy data from other sources.
VBA Code:
Sub UpdateAutoFilterClipboard()
Dim a As Variant
If ActiveSheet.AutoFilterMode = False Then
MsgBox "There is no autofilter in active sheet!"
Else
a = ClipToArray()
ActiveCell.AutoFilter Field:=ActiveCell.Column, Criteria1:=a, Operator:=xlFilterValues
End If
End Sub
Function ClipToArray() As Variant
Dim clip As New MsForms.DataObject
Dim lines As String
clip.GetFromClipboard
lines = clip.GetText
lines = Replace(lines, vbCr, "")
ClipToArray = Split(lines, vbLf)
End Function