|
質問(煮詰まった) さん、こんにちわ。
別解になりますが。
一括で読み込み、区切位置の指定で分割しています。
Sub test()
'|"AAAA,BBBB",2,3,01|→|AAAA,BBBB|2|3|01|
Dim AA As String, RR As Long, LL As Integer, Lmax As Integer
With Application.ActiveSheet
.Columns(1).NumberFormat = "@"
Open "test.csv" For Input As #1
Do Until EOF(1)
Line Input #1, AA
RR = RR + 1
.Cells(RR, 1).Value = AA
LL = Len(AA) - Len(Application.WorksheetFunction.Substitute(AA, ",", "")) 'おおよそのカンマの数
If Lmax < LL Then Lmax = LL
Loop
Close #1
ReDim fidt(1 To Lmax, 1 To 2)
For LL = 1 To Lmax
fidt(LL, 1) = LL '列番号
fidt(LL, 2) = 2 '文字列
Next
.Columns(1).TextToColumns DataType:=xlDelimited, Comma:=True, _
FieldInfo:=fidt()
End With
Erase fidt
End Sub
こんな感じです
|
|