PDA

View Full Version : Solved: Text to Column Question



vzachin
09-01-2006, 09:22 AM
Hi,

I have 2 questions
The 1st question I have if there is no data in Column B5, this will fail. How can I skip the TextToColumns if there is no data in Column B5


Range("B5:B65536").Select

Selection.TextToColumns Destination:=Range("B5"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(15, 1), Array(35, 1), Array(55, 1))


The 2nd question is instead of using Range("B5:B65536").Select, i tried to find the last row, but i don't quite understand how to write the code correctly to select B5 to last row in column B5.


iLastRow = Cells(Rows.Count, 1).End(xlUp).Row
Rows("5:" & iLastRow + 1).SpecialCells(xlCellTypeVisible).Select
Selection.TextToColumns Destination:=Range("B5"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(15, 1), Array(35, 1), Array(55, 1))




thanks
zach

Norie
09-01-2006, 09:29 AM
zach

No need to select.
iLastRow = Cells(Rows.Count, 2).End(xlUp).Row
If iRows>5 Then
Range("B5:B" & iLastRow).TextToColumns Destination:=Range("B5"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(15, 1), Array(35, 1), Array(55, 1))
End If

vzachin
09-01-2006, 10:09 AM
hi Norie,

thanks for the quick reply. that works great!


zach