Hi there.
I frequently review DAT files. These DAT files use a variety of characters as delimiters. I'm trying to devise a macro that will perform a text-to-column operation, using the content of a specified cell as the delimiter.
Here's my code, which uses þ (ASCII 0254) as a delimiter:
Instead of having the delimiter hard-coded, I'd like my macro to use whatever character I enter into Sheet3.Range("i5") as a delimiter. That way, I can easily change my delimiter character as necessary.
Any suggestions would be most appreciated.
Thanks!
I frequently review DAT files. These DAT files use a variety of characters as delimiters. I'm trying to devise a macro that will perform a text-to-column operation, using the content of a specified cell as the delimiter.
Here's my code, which uses þ (ASCII 0254) as a delimiter:
Code:
With Sheet1
Range("A1", ActiveCell.End(xlDown)).Select
Do
Selection.TextToColumns Destination:=ActiveCell.Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlSingleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar:="þ", FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
Loop Until IsEmpty(ActiveCell.Columns("A:A"))
Dim i As Long
For i = 255 To 1 Step -2
Columns(i).Delete
Next
Range("A1", Selection.End(xlToRight)).Select
Selection.Columns.AutoFit
Range("A2").Select
ActiveWindow.FreezePanes = True
End With
Instead of having the delimiter hard-coded, I'd like my macro to use whatever character I enter into Sheet3.Range("i5") as a delimiter. That way, I can easily change my delimiter character as necessary.
Any suggestions would be most appreciated.
Thanks!