Convert Short Text Field to Numeric

CBROWN1

New Member
Joined
Sep 28, 2009
Messages
43
Hi-
I am trying to convert a short text field to a numeric field in access. My data looks like the following

$1,237
$5,085
$767
($389)
($3,456)

I have tried to use the CDbl function {New_Field_Name: CDbl(Mid([USD],2,30))} and this works except where the value is a negative like ($389) and ($3,456) above.
I have also tried formatting the field New_Field_Name: Format([Table1]![Field_Name],"Standard") but to no joy.

Any suggestions will be greatly appreciated.

Thanks
C
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Maybe try using a formula similar to this.... I just tested with your sample data and the arithmetic operation is performed correctly for negative and positive numbers....

Code:
[COLOR=#0000ff]Sub[/COLOR] Test()


 [COLOR=#0000ff]   Dim[/COLOR] myTestVar [COLOR=#0000ff]As String[/COLOR]
    
    myTestVar = Range("A5")
    myTestVar = CDbl(Replace(Replace(Replace(myTestVar, "$", ""), ")", ""), "(", "-"))
    myTestVar = myTestVar + 5
    
    MsgBox myTestVar


[COLOR=#0000ff]End Sub[/COLOR]


Excel 2010
A
1$1,237
2$5,085
3$767
4($389)
5($3,456)
Sheet1


This manipulation should work in Access.
 
Last edited:
Upvote 0
Thank you so much.....a great example of me over complicating matters! Your suggestion works perfectly! :)
 
Upvote 0
Strange CDbl() works for me in all of the above cases.
 
Upvote 0

Forum statistics

Threads
1,221,816
Messages
6,162,149
Members
451,746
Latest member
samwalrus

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