View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
fbagirov fbagirov is offline
external usenet poster
 
Posts: 17
Default Converting cells from text to number format

It works great!

Although I replaced Range ("A1:A10") with Selection.

Thanks!

"Ron de Bruin" wrote:

Hi fbagirov

You can use the Left function to test the first character

You can try somthing like this
If there are spaces in the cells you must use the trim function also

Sub test()
Dim cell As Range
For Each cell In Range("A1:A10")
If Left(cell.Value, 1) = "0" Then
'do nothing
Else
cell.Value = cell.Value * 1
End If
Next cell
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"fbagirov" wrote in message ...
I get a file with a column with numbers, where the cells are formated as text
to preserve the first 0.
I need to write a macro, that will select the column, and convert all cells
to Number format. In addition, if there is a 0 in front of the number, I want
it to keep the cell in the text format and go to the next cell.

How do I write a code ? Thanks!