Parsing Data
Just be aware that TextToColumns inherits previous settings (whether from
code or from the Data/TextToColumns menu bar at the worksheet level). For
example, put this...
AAA,BBB,CCC
in A1 and then use a comma delimiter in Data/TextToColumns from the menu
bar. Now change the entry in A1 to this...
XXX, YYY, ZZZ
and run this macro...
Sub Test()
Range("A1").TextToColumns Destination:=Range("B1"), _
DataType:=xlDelimited, Space:=True
End Sub
Notice that TextToColumns retained the previously set comma delimiter and
simply added the space delimiter to the mix (thus producing the skipped
column). Now select Data/TextToColumns from the menu bar and click the Next
button once and look at the selected delimiters. Notice that both the comma
**and** the space are checked off.... the setting implemented from code has
"stuck" at the worksheet level. Just something to keep in mind when using
TextToColumns... you may want to "clean" things up before/after you use it.
--
Rick (MVP - Excel)
"pdberger" wrote in message
...
JMB --
Works great! Less filling!
Thanks!
"JMB" wrote:
I think you will have more luck using TextToColumns, with a space as the
delimiter.
"pdberger" wrote:
Good morning --
I'm trying to parse this:
A B C D
Alfred E Newman
into:
A B C D
Alfred E Newman
What I've written is:
Cells(iR, 1).Parse Destination:=Cells(iR, 2)
but it just copies the entire cell contents to the next row over. What
am I
doing wrong?
TIA
|