Many times you are faced with numeric values but the format is "Text or General", although you change the format with the usual "Format Cells" sometimes the format is not changing so the VBA below will help you.
If you are extracting the integer with a formula i.e. in column A you have
vdf01 and you enter formula - RIGHT(vdf01,2) the result will be '01' and will be formatted as "Text or General" you won't be able to get it as a Number unless you delete the "0", but if you write the formula as VALUE(RIGHT(vdf01,2)) the result will be '1' formatted as "General" but now you can change it to "Number" :-)
Copy the code to the VBA application within excel, return to your Excel book and highlight the column (range) that you want to convert and run the macro.
Sub ConvertNumber()
'We turn off calculation and screenupdating to speed up the macro.
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
For Each xCell In Selection
xCell.Value = xCell.Value
Next xCell
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
Bounce back with any questions,
No comments:
Post a Comment