简体   繁体   English

文本到列 VBA

[英]Text To Columns VBA

I'm trying the text to column but seems I have a error.我正在尝试将文本列在列,但似乎我有一个错误。 This is my Code:这是我的代码:

Set rg = Range("H3:H" & lr).CurrentRegion
rg.TextToColumns _
Destination:=Range("H3"), _
DataType:=xlDelimited, _
Tab:=False, _
Semicolon:=False, _
Comma:=False, _
Space:=False, _
Other:=True, _
OtherChar:="Chr(10)"

在此处输入图像描述

Please, test the next way.请测试下一个方法。 It splits the cells of column H:H by Chr(10) :它按Chr(10)拆分列 H:H 的单元格:

dim rg as Range
set rg=Range("H1").Entirecolumn
rg.TextToColumns destination:=rg, DataType:=xlDelimited, Other:=True, OtherChar:=Chr(10)

or splitting only the column filled range:或仅拆分列填充范围:

dim rg as Range
set rg=Range("H1:H" & Range("H" & rows.count).End(xlUp).Row)
rg.TextToColumns destination:=rg, DataType:=xlDelimited, Other:=True, OtherChar:=Chr(10)

I can show you how to (theoretically) run the code for all columns of CurrentRegion , but such an approach will be at least strange.我可以向您展示如何(理论上)为CurrentRegion的所有列运行代码,但这种方法至少会很奇怪。 I mean, splitting the first range column, all the rest of the range will be overwritten by the splitting process, everything will be ruined and nothing to be split remains ...我的意思是,拆分第一个范围列,该范围的所有 rest 将被拆分过程覆盖,一切都将被破坏,没有任何可拆分的东西......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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