berlinhammer
Board Regular
- Joined
- Jan 30, 2009
- Messages
- 187
hello all
I know of the type function in excel, e.g. =type(A1).
How do I get this information in VBA though?
I'm looping through some columns using text to columns to make numbers as text into numbers, and I want to tell the macro to only act on those cells with a cell type of 2, I can not find it in VBA though.
Please help.
Many thanks
Jon
FYI code attached
I know of the type function in excel, e.g. =type(A1).
How do I get this information in VBA though?
I'm looping through some columns using text to columns to make numbers as text into numbers, and I want to tell the macro to only act on those cells with a cell type of 2, I can not find it in VBA though.
Please help.
Many thanks
Jon
FYI code attached
Code:
Sub Text2Cols()
Dim x As Long
Dim i As Long
Dim rng As Range
x = Sheet6.Range("Data").Columns.Count
For i = 1 To x
Debug.Print i
Set rng = Sheet6.Columns(i)
Application.DisplayAlerts = False
' If rng.cells(2)....type = 2 then
rng.TextToColumns DataType:=xlDelimited
' End if
Set rng = Nothing
Next i
End Sub