+ Reply to Thread
Results 1 to 9 of 9

Converting text to number

  1. #1
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Converting text to number

    Hi there, I have a formula which extracts a number from a text string.

    the text string is in A2 - the formula which extracts the number is in B2

    However - when I copy the data in B2 and paste values to another sheet / cell - the forumla is as text - and I get the little green corner symbol and I have to convert to number.

    Please advise some VBA code - that will automatically convert my extracted "number" - to an actual number in number format.

    Thanks in advance

  2. #2
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Converting text to number

    generally, you can use the formula that you are using to extract numbers to also convert them to the proper format. if you can share the formula, we could update that.

    another option is to use the Paste Special method. put the number 1 in a blank cell - copy it and then Paste Special > Multiply over the range that needs to be converted to numerical format.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Converting text to number

    ...the text string is in A2 - the formula which extracts the number is in B2
    Without to know which is this formula, just an idea..

    Add +0 in the end of your formula in B2.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Registered User
    Join Date
    01-23-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Converting text to number

    I use asap-utilities for this, excel add on. asap-utilities.com

  5. #5
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Converting text to number

    Quote Originally Posted by icestationzbra View Post
    generally, you can use the formula that you are using to extract numbers to also convert them to the proper format. if you can share the formula, we could update that.

    another option is to use the Paste Special method. put the number 1 in a blank cell - copy it and then Paste Special > Multiply over the range that needs to be converted to numerical format.
    Well i actually have two bits of code.

    One is
    Please Login or Register  to view this content.
    One is
    Please Login or Register  to view this content.
    Both of these extract a number (where applicable) - but the number always saves as text

  6. #6
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Converting text to number

    Quote Originally Posted by Fotis1991 View Post
    Without to know which is this formula, just an idea..

    Add +0 in the end of your formula in B2.
    This actually seems to work - thank you

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Converting text to number

    You are welcome. Thanks for the reb*

  8. #8
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Converting text to number

    the INDIRECT function being used in those formulae is considered to be VOLATILE, which sort of means that the spreadsheet runs a lot of unnecessary calculations, making it processor intensive.

    as far as i could understand, in your specific case, INDIRECT("p"&ROW()) translates to INDEX(P:P,ROW()), which is non-VOLATILE and really really fast.

    if you share some sample data and expected results, i have a hunch that we can simplify and enhance the formulae.


    UPDATE:

    this formula may not seem shorter / simpler, but it will be faster / efficient (and give you numerical output, too) over large ranges of data:

    Please Login or Register  to view this content.
    when compared with,

    Please Login or Register  to view this content.
    Last edited by icestationzbra; 01-25-2013 at 01:11 PM.

  9. #9
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Converting text to number

    Sorry, only just seen this response. Thanks for the tips, my formula's can no doubt be improved for speed. I have a lot of calculations involved - and probably not working at the most efficient way.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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