VBA to convert text to a number

windsurfit

Board Regular
Joined
Mar 27, 2003
Messages
228
My sheet contains many cells (also entire rows and columns) that have data sorted from another sheet. Many results have "text" values that I need converted to numeric.

I want to convert more than one cell at a time (as is done under error checking) using a Macro. Ideally the whole sheet or at least a column at a time.

Hopefully this is fairly simple.

Thx
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
My sheet contains many cells (also entire rows and columns) that have data sorted from another sheet. Many results have "text" values that I need converted to numeric.

I want to convert more than one cell at a time (as is done under error checking) using a Macro. Ideally the whole sheet or at least a column at a time.
Give this a try...
Code:
Sub ConvertTextNumbersToRealNumbers()
  With ActiveSheet.UsedRange
    .NumberFormat = "General"
    .Value = .Value
  End With
End Sub
 
Upvote 0
Hi Rick,

Thanks- it seems to work..will try the upload to my internal software and see if it chokes...

Your the best.
 
Upvote 0
Hey,

OK- after running tests it appears that I don't want the whole sheet converted just specific columns of data..
In this case columns: C:K (only).

Hopefully this is a simple modification to the above.

Thx again..
 
Upvote 0
OK- after running tests it appears that I don't want the whole sheet converted just specific columns of data..
In this case columns: C:K (only).
This should work...
Code:
Sub ConvertTextNumbersToRealNumbers()
  With Intersect(ActiveSheet.UsedRange, Columns("C:K"))
    .NumberFormat = "General"
    .Value = .Value
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,522
Messages
6,114,112
Members
448,549
Latest member
brianhfield

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