Convert from text to numbers

aviadht

Board Regular
Joined
Aug 7, 2008
Messages
91
Hi,

How can i write in vba code that take a range of text and convert it to number ?

Thanks,
Aviad
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try something like this:

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Macro1()<br><br>    Range("E2:E17").NumberFormat = "0"<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
If Trevor's code doesn't work, try this:
1) Enter into some cell 1 and copy this cell with Ctrl+C.
2) Select your range.
3) Right-click on this range and select "Paste Special..."
4) In "Paste" section choose "Values" and in "Operation" section choose "Multuply."
 
Upvote 0
Just an update for the vba to do this, in case anyone is looking for it:

Select the range of cells to convert to numbers and run the following:

Code:

Sub Convert_To_Number()
For Each xCell In Selection
xCell.Value = CDec(xCell.Value)
Next xCell

End sub

\Code

Hope this helps if you're looking...
 
Upvote 0
j844929,

You may find
Code:
Sub x()
Selection.Value = Selection.Value
End Sub
is briefer, faster, and less prone to error.

Assuming, as all of this seems to, is that the "text" is numbers stored as text.
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top