LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Converting cells from text to number format

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!

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
To display number in text format in cells Man T New Users to Excel 7 July 1st 08 12:35 PM
Converting numbers stored as text into number-format kassie Excel Programming 2 October 22nd 06 11:57 AM
converting general cells format to text junkgrrl Excel Discussion (Misc queries) 1 January 12th 06 05:50 PM
Converting number or text to a Date Format samhain New Users to Excel 2 October 17th 05 02:28 PM
Keep number format after converting time to text DH Excel Discussion (Misc queries) 2 April 28th 05 07:18 PM


All times are GMT +1. The time now is 06:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"