+ Reply to Thread
Results 1 to 7 of 7

How to strip currency symbol from textbox

  1. #1
    Forum Contributor
    Join Date
    12-06-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    203

    How to strip currency symbol from textbox

    How can I strip a currency symbol from a textbox that has been formatted as currency? I only want the value of the textbox without any other characters. When I Exit the textbox I want to write the value without the currency symbol to another textbox.

    Val() doesn't work because it encounters the currency symbol before the actual value so returns 0.

    My currency symbol is a 'R' but it could be any other currency as well.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,989

    Re: How to strip currency symbol from textbox

    You can't format a textbox as currency so either the currency symbol is being entered manually or it's being added in code. Neither one is a good idea. If you could have multiple currencies being entered on the same computer, you can't use CCur either.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    11-14-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    100

    Re: How to strip currency symbol from textbox

    I use =LEFT(A1,FIND(" ",A1)-1) to take only numbers from a cell containing numbers and letters where A1 = 240 MH/s

    if that helps

  4. #4
    Forum Contributor
    Join Date
    12-06-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    203

    Re: How to strip currency symbol from textbox

    Romperstomper: Yes. It's formatted through code. It's simply done to display a view textbox where the value is displayed as currency (to make it look good).

    But when the user needs to change the value it gets changed in the view textbox that is then transferred to the hidden textbox where it's not currency. This works when the amount is changed as the text, including the currency symbol, in the view textbox is selected and the amount entered replaces the currency symbol and the amount. On the exit of the view textbox the value is then transferred to the hidden textbox and the amount in the view textbox is again formatted to display as currency.

    When it doesn't work is when the user tabs through the view textbox without changing the value. In this case the currency symbol is still in the view textbox and is then transferred, on exit, to the hidden textbox along with the value

    Semajjames: Your example has pointed me in a good direction. Working on a function to extract only numbers from the textbox text.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,989

    Re: How to strip currency symbol from textbox

    If you added the symbol in the code, you should know what it is, and it would be a simple replace call or, if it's the user's local currency, you can simply use CCur. For example, since my regional currency is £, CCur("£1.25") will return 1.25

  6. #6
    Forum Contributor
    Join Date
    12-06-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    203

    Re: How to strip currency symbol from textbox

    Problem is when you're working with exchange rates. Then you're working with all currency symbols except Zim$ of course. Not enough space on a screen for a textbox long enough to display that currency

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,989

    Re: How to strip currency symbol from textbox

    So your code didn't add the symbol then?

    At any rate, I would suggest a separate box for the currency identifier - it will make life simpler.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Currency conversion insert currency symbol
    By siobeh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-01-2013, 05:50 AM
  2. [SOLVED] Add Currency symbol in textbox
    By siobeh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2013, 02:02 AM
  3. [SOLVED] Currency symbol always in box
    By shiftyspina in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-21-2013, 07:08 PM
  4. Excel 2007 : Currency symbol
    By nlm in forum Excel General
    Replies: 7
    Last Post: 01-09-2012, 02:29 AM
  5. Replies: 5
    Last Post: 11-18-2010, 05:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1