VBA convert string into double

ww4612

Well-known Member
Joined
Apr 24, 2014
Messages
515
those following numbers are stored as string. I would like to convert them into double. I tried to used VBA recorder. But it does not record the code.
any solutiom?
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]0.0016
[/TD]
[TD][TABLE="width: 64"]
<colgroup><col width="64"></colgroup><tbody>[TR]
[TD="class: xl65, width: 64"]2,815,993[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 64"]
<colgroup><col width="64"></colgroup><tbody>[TR]
[TD="class: xl65, width: 64"]0.02%[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]1.00
[/TD]
[TD]1.663E-06
[/TD]
[/TR]
</tbody>[/TABLE]
 
You should be able to use the WorksheetFunction.Text to do the conversions. Consider the following...
Code:
Sub Test()

  Dim StringValue As String, DoubleValue As Double
  
  StringValue = "2,815,993"
  MsgBox WorksheetFunction.Text(StringValue, "General")
  
  StringValue = "0.02%"
  MsgBox WorksheetFunction.Text(StringValue, "General")

End Sub
thank you for the code. it works well.
 
Upvote 0
Hi Rick,

Thank you for the clear explanation; very helpful :-)

Mark
 
Upvote 0

Forum statistics

Threads
1,226,788
Messages
6,192,982
Members
453,771
Latest member
TomBird

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