Friday, June 26, 2020

Performing Text to Column automatically using VBA

I have a string variable containing a string which contains lots of "|" character,I need to do a text to column using VBA,My string variable in in cell A1

Sub Macro1()
'
' Macro1 Macro
'

'
Dim rng As Range
Set rng = Range("A1")


    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
        :="|", TrailingMinusNumbers:=True
       
'        Selection.TextToColumns _
'      Destination:=Range("A2"), _
'      DataType:=xlDelimited, _
'      TextQualifier:=xlDoubleQuote, _
'      ConsecutiveDelimiter:=False, _
'      Tab:=True, _
'      Semicolon:=False, _
'      Comma:=False, _
'      Space:=False, _
'      Other:=True, _
'      OtherChar:="-"
End Sub

No comments:

Post a Comment