我試圖找出如何將文本循環到列代碼。希望得到它的循環,直到最後的數據或可能是空的行/單元格。儘管我可能有超過60份材料清單。感謝任何人都可以幫忙。 :)Excel VBA'文本到列'循環
'Material 1
Range("A2").Select
Selection.TextToColumns Destination:=Range("B2"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(16, 1), Array(58, 1), Array(65, 1)), _
TrailingMinusNumbers:=True
Range("A3").Select
Selection.TextToColumns Destination:=Range("F2"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(11, 1), Array(25, 1), Array(37, 1), Array(40, 1), _
Array(43, 1), Array(54, 1), Array(64, 1), Array(73, 1)), TrailingMinusNumbers:=True
Range("A4").Select
Selection.TextToColumns Destination:=Range("O2"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 9), Array(26, 1), Array(63, 1)), TrailingMinusNumbers _
:=True
'Material 2
Range("A5").Select
Selection.TextToColumns Destination:=Range("B5"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(16, 1), Array(58, 1), Array(65, 1)), _
TrailingMinusNumbers:=True
Range("A6").Select
Selection.TextToColumns Destination:=Range("F5"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(11, 1), Array(25, 1), Array(37, 1), Array(40, 1), _
Array(43, 1), Array(54, 1), Array(64, 1), Array(73, 1)), TrailingMinusNumbers:=True
Range("A7").Select
Selection.TextToColumns Destination:=Range("O5"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 9), Array(26, 1), Array(63, 1)), TrailingMinusNumbers _
:=True
'Material 3
Range("A8").Select
Selection.TextToColumns Destination:=Range("B8"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(16, 1), Array(58, 1), Array(65, 1)), _
TrailingMinusNumbers:=True
Range("A9").Select
Selection.TextToColumns Destination:=Range("F8"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(11, 1), Array(25, 1), Array(37, 1), Array(40, 1), _
Array(43, 1), Array(54, 1), Array(64, 1), Array(73, 1)), TrailingMinusNumbers:=True
Range("A10").Select
Selection.TextToColumns Destination:=Range("O8"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 9), Array(26, 1), Array(63, 1)), TrailingMinusNumbers _
:=True
感謝您的幫助!非常感謝。將很快嘗試此代碼,並讓您知道結果。並會檢查出截圖。 – Zawawi 2014-12-14 03:25:57