+ Reply to Thread
Results 1 to 21 of 21

text to numbers

  1. #1
    Registered User
    Join Date
    02-25-2015
    Location
    Atlanta, GA
    MS-Off Ver
    2013
    Posts
    97

    text to numbers

    I get a report in every day and column A comes in as text with a - sign as the last character

    Column A
    5498-
    75-
    32-
    90-

    I have been using =IF( LEN( A1 )<>0, VALUE(LEFT(A1,LEN(A1)-1)), "" ) to convert to numbers but it does not seem to work all the time. Is there an error with my formula?

    Thanks

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: text to numbers

    Try highlighting the problematic numbers
    Data - Text To Columns
    Deliminated - Next
    UNcheck all options - Next
    Click Advanced, check "Trailing minus for negative numbers"
    OK
    Finish

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,869

    Re: text to numbers

    Along the same lines, you might look at the process you are using to import these numbers. If you are going through the text import wizard, the same option should be available as part of that dialog. Then you can catch these trailing minus numbers at the point of importation rather than fixing it after the data are imported.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: text to numbers

    Actually, we may have misunderstood the intention..
    Are those numbers supposed to be positive? And the - is actually just superfluous ?

    If that's the case, then still Text To Columns, but put a check on Other and enter a - as the Delimiter.

  5. #5
    Registered User
    Join Date
    02-25-2015
    Location
    Atlanta, GA
    MS-Off Ver
    2013
    Posts
    97

    Re: text to numbers

    I can do it manually. The numbers are positive.


    72- text would be 72 number

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: text to numbers

    Another option...

    Select the range of cells in question

    Press the key combo of CTRL + H

    The Find/Replace userform opens

    Find what: -
    Replace with: nothing, leave this blank
    Replace All
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Registered User
    Join Date
    02-25-2015
    Location
    Atlanta, GA
    MS-Off Ver
    2013
    Posts
    97

    Re: text to numbers

    That is doing it manually without a formula to do the work. I was looking for a formula to do the work. It works great till I close down and reopen and then it does not work...lol

    Thanks

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: text to numbers

    Well the formula you posted works just fine with the examples you posted.
    In what way does it not work for you 'sometimes' ?
    Do you get an error? What error?

    Post an example value that exists in A1 when the formula doesn't work.

    This might be a simpler formula
    =SUBSTITUTE(A1,"-","")+0


    And I'll second MrShorty's thought of looking at your process that brings the data in to begin with.
    Maybe it can be adjusted to not include that -

  9. #9
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: text to numbers

    With VALUE(text) text can be in any of the constant number, date, or time formats recognized by Microsoft Excel. If text is not in one of these formats, VALUE returns the #VALUE! error value.
    you can try very similar formula: =IF(LEN(A1)<>0,--LEFT(A1,LEN(A1)-1),"") or if it doesn't work, show us value when formula generate error.

  10. #10
    Registered User
    Join Date
    02-25-2015
    Location
    Atlanta, GA
    MS-Off Ver
    2013
    Posts
    97

    Re: text to numbers

    Later today I will post more info...I have a meeting to attend in a few...

    I appreciate the help!

  11. #11
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: text to numbers

    --LEFT will suffer the same fate as VALUE when the value it looks at is not numeric.
    You'd have to trap that error with IFERROR or some other error testing function.

  12. #12
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: text to numbers

    Jonmo1,
    but it is shorter and less brackets

  13. #13
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: text to numbers

    @sandy666
    The way you posted it seemed like you were saying --LEFT would somehow avoid the #Value! error.
    And Shorter <> Better or Faster, only fewer keystrokes.

  14. #14
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: text to numbers

    Jonmo1,
    Are you suggesting that the use -- it is a bad thing?
    I have quoted only MS Help
    The rest depends on the interpretation
    I think it is the academic ongoing discussions

  15. #15
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: text to numbers

    Quote Originally Posted by sandy666 View Post
    Are you suggesting that the use -- it is a bad thing?
    Not at all.
    Just that it's not any better or worse than Value. Either way works fine.

    I didn't mean to offend you, sorry if you took it that way.

    I really only wanted to clarify that --LEFT will not avoid the #Value! Error when the value it evaluates is not numeric.
    The way your first post was written implied that it would, and that it may have been the problem with OP's original formula.
    Last edited by Jonmo1; 12-17-2015 at 03:55 PM.

  16. #16
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: text to numbers

    Jonmo1,

    I do not feel offended in any way

    You are right without a doubt
    Maybe I used too much mental shortcut in my first post, but just in this case (--) vs Value is better (mean: shorter, 2 vs 7 keystrokes) , what is not soultion for #VALUE, of course. So I said in next words: show us that case when you get an error. No more, no less.

  17. #17
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: text to numbers

    Fair enough.

    But my other point is about "Shorter <> Better"
    And I'm NOT saying that yours isn't better (or worse) in any way. I'm completely indifferent on that.

    But for future FYI
    Just because code A is shorter than code B does not mean A is better or faster or more effective than B.
    Many other factors often need to be considered to determine which is better for any given situation.

    Example:
    =A1+B1
    =SUM(A1,B1) or SUM(A1:B1)

    SUM has a HUGE advantage over simple +, in that it will ignore text entries in A1 or B1, where the + will result in #Value!
    Last edited by Jonmo1; 12-17-2015 at 04:10 PM.

  18. #18
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: text to numbers

    Of course, but I said:
    Quote Originally Posted by sandy666 View Post
    (...) but just in this case (--) vs Value is better (mean: shorter, 2 vs 7 keystrokes) (...)
    I agree with you in principle, that not every time shorter mean better.

  19. #19
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: text to numbers

    We'll just have to agree to disagree, and stop hijacking the thread.

    Sorry to OP.

  20. #20
    Registered User
    Join Date
    02-25-2015
    Location
    Atlanta, GA
    MS-Off Ver
    2013
    Posts
    97

    Re: text to numbers

    I want to thank everyone help...It was the 0 coming in that cause me problems....

    I ended up using Jonmo1 formula ​=SUBSTITUTE(A1,"-","")+0

    Because if text was a 0 it would give me a 0

    If for some odd reason o instead of 0 come in as text =IFERROR(SUBSTITUTE(A1,"-","")+0, 0) would subsutute the o to 0 without the error message

    Thanks for all help!

  21. #21
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: text to numbers

    You're welcome

+ 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. Replies: 19
    Last Post: 07-20-2014, 04:55 PM
  2. [SOLVED] Marco to convert numbers stored as text to numbers and dates stored as text to numbers
    By a2424 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-22-2014, 10:19 AM
  3. [SOLVED] [SOLVED] Macro/Wildcard to remove only numbers excluding text with numbers
    By indianhp in forum Word Programming / VBA / Macros
    Replies: 6
    Last Post: 06-21-2013, 08:16 AM
  4. [SOLVED] Convert all numbers stored as text or custom formatted to numbers &no decimals - 40 sheets
    By synses in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2013, 01:46 AM
  5. Replies: 9
    Last Post: 03-26-2012, 02:16 PM
  6. Replies: 17
    Last Post: 03-03-2010, 06:55 PM
  7. [SOLVED] VLOOKUP should compare numbers stored as text to plain numbers.
    By VLOOKUP - Numbers stored as text in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-31-2006, 12:55 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