Convert String variable to Numeric, VBA

jcauteru

New Member
Joined
Jul 27, 2010
Messages
15
Hi,

I have a string variable which I would like to convert to a numeric variable. For instance, the data in the string variable may be "02", I would like the numeric variable to be "2". Can't seem to quite get it.

Thanks,

Joe

Code:
model_code = Sheet.Cells(rownum, CampaignCol).Text
model_code_txt = (Mid(model_code, 9, 2))
model_code_num = CInt(model_code_txt) 'It errors out here. 
model_code_ex(rownum) = model_code_num
Sheet.Cells(rownum, 208) = model_code_ex(rownum)
Debug.Print model_code_ex(rownum)
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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