Best to explicitly disable the unwanted separators and enable the desired
separator. From the Recorder, this splits on the character "c":
Sub Macro1()
Selection.TextToColumns Destination:=Range("C4"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,
Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="c", FieldInfo:=Array(Array(1, 1), Array(2, 1)),
TrailingMinusNumbers:=True
End Sub
--
Gary''s Student
gsnu200712
"Steve" wrote:
> Hi,
>
> I have a macro that has been written to open to different text files
> (using Excel), retreiving some data and bringing it back into my
> workbook, (bits shown below). At the end of my macro, I have a column
> that I have to use the Text-to-Columns feature using a comma as the
> delimiter. All of this works fine until I go to use the macro on a
> different file, then it remembers the comma delimiter from that last
> part of the macro and therefore won't work again from the beginning
> when opening the two text files to retreive data, which by the way
> were defaulting to us a "tab" delimiter. I tried adding some
> information to macro to the part where I open the text files, however
> my macro kept stopping there. Any help would be certainly
> appreciated.
>
>
>
> Thanks,
>
> Steve
>
>
> Dim wkbCurrent As Workbook
> Set wkbCurrent = ActiveWorkbook
>
> Workbooks.Open Filename:="\\smdsldb01\jobscan\Alt_Items_List.txt"
>
>
>
> Dim wkbCurrent2 As Workbook
> Set wkbCurrent2 = ActiveWorkbook
>
> Workbooks.Open Filename:="\\smdsldb01\jobscan
> \Drawing_Nbr_List.txt"
>
>
>
> Columns("L:L").Select
> Selection.TextToColumns Destination:=Range("L1"),
> DataType:=xlDelimited, _
> TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,
> Tab:=False, _
> Semicolon:=False, Comma:=True, Space:=False, Other:=False,
> FieldInfo _
> :=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
>
>
|