简体   繁体   中英

Text to columns - issue with commas

I am trying to seperate my columns with vba. This is how my data looks:

first row:

Time,[CB:01:4A:7D:06:2D] Thermometer_0,[E5:39:8E:7F:E4:11] Thermometer_0,[F1:89:F8:3A:EA:63] Thermometer_0,[F7:C6:4A:56:E4:23] Thermometer_0

second row:

11/23/2021 10:50,,,,20.9

That means that I need to have 11/23/2021 10:50 in the first column (Time), second, third and fourth are empty, and in the fifth value 20.9. There are variations for the second row.

Currently I am trying with this code:

Sub TextToCol3()
   Range("A1:A135").TextToColumns , xlDelimited, xlDoubleQuote, True, , , True, True, True
End Sub

But this just ignore the empty spaces between commas, and creates only two columns.

Please, test the next way:

Range("A1:A135").TextToColumns DataType:=xlDelimited, ConsecutiveDelimiter:=False, Comma:=True

If ConsecutiveDelimiter = True , the consecutive delimiters are considered as one delimiter ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM