VBA中分列代码怎么写?

2026年09月24日 15:03
有2个网友回答
网友(1):

A列按”  ,  “号分裂:


Sub test()
Columns("a:a").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
End Sub

网友(2):

用逗号分列的vba代码如下:
sub 宏1()
    selection.texttocolumns destination:=range("a1"), datatype:=xldelimited, _
        textqualifier:=xldoublequote, consecutivedelimiter:=false, tab:=false, _
        semicolon:=false, comma:=true, space:=false, other:=false, trailingminusnumbers:=true
end sub