|
2つ作ってました。
Sub Test_Parse()
Dim i As Integer
Dim Buf As String
On Error GoTo ErLine
With ActiveCell
For i = 1 To Len(.Value)
Buf = Buf & "[" & .Characters(i, 1).Text & "]"
Next i
.Parse Buf
End With
ErLine:
End Sub
Sub Test_Split()
Dim i As Integer
Dim Buf As String
Dim StAry As Variant
On Error GoTo ErLine
With ActiveCell
For i = 1 To Len(.Value)
Buf = Buf & .Characters(i, 1).Text & ","
Next i
StAry = Split(Buf, ",")
.Resize(, Len(.Value)) = StAry
End With
ErLine:
End Sub
Split関数を使うコードは、Excel2000以降でないとエラーに
なると思います。その場合 Dim StAry As Variant を削除して
>StAry = Split(Buf, ",")
>.Resize(, Len(.Value)) = StAry
↓
.TextToColumns DataType:=xlDelimited, Comma:=True
と変更すれば、Excel5.0以降の全バージョンで使えます。
|
|