Convert Text to Numbers via VBA

Snap Happy

New Member
Joined
Dec 8, 2009
Messages
18
I'm sure my issue has been covered before but I can't find the solution I need.I receive an Excel report from a third party where some of the columns are 'Number Stored as Text'. I can convert these manually using the highlight and 'Convert to Numbers' on the drop down but I need to do this automatically using VBA code.I select the fields usingRange(Selection,Selection.End(xlDown)).Selectbut can't figure out the next step to convert to numbers.Can anyone help?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try selecting them, Data > Text to Columns and click Finish. You can record a macro whilst doing this.
 
Upvote 0
Hi

Try this, it will work under a command button.

Code:
For Each Convert In Range("B4:b10")
Convert.Offset(0, 1).Value = "=VALUE(RC[-1])"
Convert.Value = Convert.Offset(0, 1).Value
Convert.Offset(0, 1).Delete
 
 
Next Convert


regards

Kev

P.S Range B4:B15 is the range of date to change, alter to suit
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
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