Rowland Hamilton
Active Member
- Joined
- Nov 13, 2009
- Messages
- 250
Folks:
Found this Macro that works to Convert Text to Numbers:
Problem is it "breaks" when it encounters text that can not be converted to a number:
How do I allow for type mismatch?
Also tried this Macro that only worked once:
Thank you - Rowland
Macro Convert Text to Numbers Allow Type mismatch
Found this Macro that works to Convert Text to Numbers:
Code:
Sub Enter_Values()
For Each xCell In Selection
xCell.Value = CDec(xCell.Value)
Next xCell
End Sub
Problem is it "breaks" when it encounters text that can not be converted to a number:
Code:
Run-time error '13': Type mismatch
How do I allow for type mismatch?
Also tried this Macro that only worked once:
Code:
Sub ConvertToNumbers() 'won't work after first time
Cells.SpecialCells(xlCellTypeLastCell) _
.Offset(1, 1).Copy
Selection.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlPasteSpecialOperationAdd
With Selection
.VerticalAlignment = xlTop
.WrapText = False
End With
Selection.EntireColumn.AutoFit
End Sub
Thank you - Rowland
Macro Convert Text to Numbers Allow Type mismatch