Code: Select all
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, Comma:=True, _
FieldInfo:=Array(Array(1, 2), Array(2,2))
Thanks,
Ken
Code: Select all
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, Comma:=True, _
FieldInfo:=Array(Array(1, 2), Array(2,2))
Code: Select all
Sub T2C()
Dim arrValue As Variant
Dim arrFormats As Variant
Dim i As Long
Dim n As Long
' Split the first cell into an array
arrValue = Split(Selection.Cells(1).Value, ",")
' Number of columns - 1
n = UBound(arrValue)
ReDim arrFormats(n)
' Fill array with format specifications
For i = 0 To UBound(arrValue)
arrFormats(i) = Array(i + 1, xlTextFormat)
Next i
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, Comma:=True, _
FieldInfo:=arrFormats
End Sub
Code: Select all
arrValue = Split(Selection.Cells(2).Value, ",")
Code: Select all
arrValue = Split(Selection.Cells(2).Value, ",")
Code: Select all
arrValue = Split(Selection.Cells(n).Value, ",")
Code: Select all
arrValue = Split(Selection.Cells(maxRow).Value, ",")
Code: Select all
Sub T2C()
Dim arrFormats As Variant
Dim r As Long
Dim m As Long
Dim v As Long
Dim i As Long
Dim n As Long
m = Range("A" & Rows.Count).End(xlUp).Row
' Determine max number of columns
For r = 2 To m
v = Len(Range("A" & r).Value) - Len(Replace(Range("A" & r).Value, ",", ""))
If v > n Then n = v
Next r
ReDim arrFormats(n)
' Fill array with format specifications
For i = 0 To n
arrFormats(i) = Array(i + 1, xlTextFormat)
Next i
Range("A1:A" & m).TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, Comma:=True, _
FieldInfo:=arrFormats
End Sub
Code: Select all
v = Len(Range("A" & r).Value) - Len(Replace(Range("A" & r).Value, ",", ""))