Below code converts text to number except values with prefix 0 I.E. 002A.
This code works on small data files but crashes Excel on large files even though I turn off calculation before code runs.
vba
Sub Text2Number()
On Error GoTo EH
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Set Rng = ActiveSheet.UsedRange
Rng.Cells(1, 1).Select
For i = 1 To Rng.Rows.Count
For j = 1 To Rng.Columns.Count
If Rng.Cells(i, j) <> "" Then
Union(Selection, Rng.Cells(i, j)).Select
End If
Next j
Next i
For Each c In Rng.Cells
If IsNumeric(c.Value) And Left$(c.Value, 1) <> "0" Then
c.NumberFormat = "General"
c.Value = c.Value
End If
Next
Rng.HorizontalAlignment = xlLeft
CleanUp:
On Error Resume Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Exit Sub
EH:
' Do error handling
Resume CleanUp
End Sub