You want to explicitly set the DataType
to xlDelimited
, otherwise Excel assumes that the data is arranged in fixed-width columns, and Excel first assumes how wide these columns are, where spaces - ignore any separators, select in the argument list.
Try the following and you will see that it reproduces your results:
Range("A1").TextToColumns DataType:=xlFixedWidth
which gives the same results as the DataType
argument:
Range("A1").TextToColumns
Note that the Excel documentation is erroneous in this regard: it says xlDelimited
is the default, but it is clear that xlFixedWidth
is the default value in reality.
So, a long story, what you need is the following:
Range("A1").TextToColumns DataType:=xlDelimited, Comma:=True, Space:=False
EDIT It looks like the Excel documentation may be wrong. It really smells like a bug in Excel-VBA. See the discussion in the comments below.
Jean-FranΓ§ois Corbett
source share