G
Guest
I have a data sheet that ocassionally has the lower half values remain as
text when I copy new data. I have produced the following macro to convert
the selected cols to either date or number format. There are many more
columns to convert to number format than shown. I've trimmed some of the
default code entered by the macro recorder to what I think is the minimum
required. Is there a more compact version of the code I can use to get the
same result. I also wan this to run on cahnges to the sheet (ie; when new
data is copied in).
Sub ColToNum()
Columns("K:K").Select 'number format
Selection.TextToColumns , DataType:=xlDelimited, FieldInfo _
:=Array(1, 1)
Columns("M:M").Select 'number format
Selection.TextToColumns , DataType:=xlDelimited, FieldInfo _
:=Array(1, 1)
Columns("Q:Q").Select 'number format
Selection.TextToColumns , DataType:=xlDelimited, FieldInfo _
:=Array(1, 1)
Columns("R:R").Select 'number format
Selection.TextToColumns , DataType:=xlDelimited, FieldInfo _
:=Array(1, 1)
Columns("E:E").Select 'date format
Selection.TextToColumns , DataType:=xlDelimited, FieldInfo _
:=Array(1, 4)
Columns("G:G").Select 'date format
Selection.TextToColumns , DataType:=xlDelimited, FieldInfo _
:=Array(1, 4)
End Sub
Any suggestions appreciated.
text when I copy new data. I have produced the following macro to convert
the selected cols to either date or number format. There are many more
columns to convert to number format than shown. I've trimmed some of the
default code entered by the macro recorder to what I think is the minimum
required. Is there a more compact version of the code I can use to get the
same result. I also wan this to run on cahnges to the sheet (ie; when new
data is copied in).
Sub ColToNum()
Columns("K:K").Select 'number format
Selection.TextToColumns , DataType:=xlDelimited, FieldInfo _
:=Array(1, 1)
Columns("M:M").Select 'number format
Selection.TextToColumns , DataType:=xlDelimited, FieldInfo _
:=Array(1, 1)
Columns("Q:Q").Select 'number format
Selection.TextToColumns , DataType:=xlDelimited, FieldInfo _
:=Array(1, 1)
Columns("R:R").Select 'number format
Selection.TextToColumns , DataType:=xlDelimited, FieldInfo _
:=Array(1, 1)
Columns("E:E").Select 'date format
Selection.TextToColumns , DataType:=xlDelimited, FieldInfo _
:=Array(1, 4)
Columns("G:G").Select 'date format
Selection.TextToColumns , DataType:=xlDelimited, FieldInfo _
:=Array(1, 4)
End Sub
Any suggestions appreciated.