convert a range of text into numbers
Sounds like you want a subroutine that you can pass in a range of cells.
The following routine ignores cells that are blank or contain formulas. It
only works on non-empty cells that contain text values that are numeric.
'----------------------------------------------------------------------
Public Sub ChangeTextValuesToNumbers(MyRange As Range)
Dim rngCell As Range
If MyRange Is Nothing Then Exit Sub
For Each rngCell In MyRange
With rngCell
If Not .HasFormula And Not IsEmpty(rngCell) _
Then
If IsNumeric(rngCell) _
Then
'Convert value to double and paste back in cell.
.Value = CDbl(.Value)
End If
End If
End With
Next rngCell
End Sub
To use, call it and pass in a range of cells, like so:
ChangeTextValuesToNumbers Range("A1:A5")
--
Regards,
Bill Renaud
|