Hi I'm trying to convert all text '0 to numbers while skipping '00, percents, formulas, etc..
I'm using the code below but I keep getting "Run-Time error '13': Type Mismatch"
Any ideas what I'm doing wrong or how to fix?
I'm using the code below but I keep getting "Run-Time error '13': Type Mismatch"
Any ideas what I'm doing wrong or how to fix?
Code:
Sub TextToNumber()
Dim x As Worksheet, z As Range
For Each x In Worksheets
Sheets(x.Name).Activate
Range("a1").Select
ActiveCell.SpecialCells(xlLastCell).Select
LastCell = ActiveCell.Address
Range("a1:" & LastCell).Select
For Each z In Selection
If Not IsEmpty(z) _
And Len(z.Value) = 1 _
And Application.IsText(z) _
And IsNumeric(z.Value) _
And Not z.HasFormula _
And Not Left(z.Value, 2) = "0." _
And Left(z.Value, 1) = "0" Then
z.Value = z.Value
z.NumberFormat = "_(* #,##0_);_(* (#,##0);_(* ""-""_);_(@_)"
End If
Next z
Range("a1").Select
Next x
End Sub