+ Reply to Thread
Results 1 to 12 of 12

Need HELP replacing multiple numbers with just one number

  1. #1
    Registered User
    Join Date
    11-24-2015
    Location
    Houston, TX
    MS-Off Ver
    Office 2013
    Posts
    3

    Question Need HELP replacing multiple numbers with just one number

    I have a long spreadsheet and in one column, I need to:
    1) find all numbers which are -1 and lower, and replace with just the number "-1"
    2) leave "0" as "0"
    3) find all numbers which are +1 and higher, and replace with just the number "1".

    Here's part of the spreadsheet:

    209
    117
    -218
    274
    237
    0
    -123
    -36
    12
    etc ...

    I've searched and searched, but have not found a solution yet. Any help would be GREATLY appreciated!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Need HELP replacing multiple numbers with just one number

    Welcome to the board.

    Row\Col
    A
    B
    C
    1
    209
    1
    B1: =MIN(1, MAX(A1, -1))
    2
    117
    1
    3
    -218
    -1
    4
    274
    1
    5
    237
    1
    6
    0
    0
    7
    -123
    -1
    8
    -36
    -1
    9
    12
    1
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need HELP replacing multiple numbers with just one number

    Hi,

    Personally I'd use a helper column. e.g.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    copy this down, then copy the whole column and paste it back to A1 as Values.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    11-24-2015
    Location
    Houston, TX
    MS-Off Ver
    Office 2013
    Posts
    3
    Quote Originally Posted by shg View Post
    Welcome to the board.

    Row\Col
    A
    B
    C
    1
    209
    1
    B1: =MIN(1, MAX(A1, -1))
    2
    117
    1
    3
    -218
    -1
    4
    274
    1
    5
    237
    1
    6
    0
    0
    7
    -123
    -1
    8
    -36
    -1
    9
    12
    1
    .

    Thank you. Is that done as a find/replace?

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

    Re: Need HELP replacing multiple numbers with just one number

    For a third option, I would probably use the =SIGN() function: https://support.office.com/en-us/art...1-2dd0e916a1d8
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Registered User
    Join Date
    11-25-2012
    Location
    Swansea, Wales
    MS-Off Ver
    Excel 2003
    Posts
    55

    Re: Need HELP replacing multiple numbers with just one number

    Something like the following?


    Please Login or Register  to view this content.
    Last edited by Wales MB; 11-24-2015 at 05:43 PM.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need HELP replacing multiple numbers with just one number

    Quote Originally Posted by MrShorty View Post
    For a third option, I would probably use the =SIGN() function:
    Of course! The simpler the better. An example to us all to occasionally review and remind ourselves of these little used functions. Well done.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Need HELP replacing multiple numbers with just one number

    Reckon it depends on what you want the result to be for numbers between -1 and 1.

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

    Re: Need HELP replacing multiple numbers with just one number

    Quote Originally Posted by shg View Post
    Reckon it depends on what you want the result to be for numbers between -1 and 1.
    The OP did not say what to do with numbers between +1 and -1. Since all examples given were for "integer" inputs, and nothing was mentioned about fractional values in between +1 and -1, I assumed that all inputs will be integers, so there is nothing between +1 and -1, except for exactly 0. If the possible input set is "all reals", then I would suggest that the OP more carefully define what should be returned in that "undefined" region. Right now, shg's function returns the input value, Richard's function would return empty string "", and Wales MB's would return 0, where mine will return +1 or -1, depending on whether the fraction input is greater than 0 or less than 0.

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need HELP replacing multiple numbers with just one number

    Quote Originally Posted by shg View Post
    Reckon it depends on what you want the result to be for numbers between -1 and 1.
    Good point.
    The OP seemed to imply only integers so probably there never would be stuff like -0.5 but who knows....

  11. #11
    Registered User
    Join Date
    11-24-2015
    Location
    Houston, TX
    MS-Off Ver
    Office 2013
    Posts
    3

    Re: Need HELP replacing multiple numbers with just one number

    Quote Originally Posted by Richard Buttrey View Post
    Good point.
    The OP seemed to imply only integers so probably there never would be stuff like -0.5 but who knows....
    .

    No it's whole numbers only; no decimals.

  12. #12
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Need HELP replacing multiple numbers with just one number

    @Extender,

    Please do not use the PM facility for raising questions about your thread. That's specifically contrary to our rukes.
    Ask them here: that's what it's here for. However don't expect many of us to go to other file hosting sites to see your workbook. Upload it here if you want further help.

+ 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. [SOLVED] Auto Find Numbers & Auto Replacing Another number
    By TLRam1 in forum Excel General
    Replies: 17
    Last Post: 08-12-2015, 03:38 PM
  2. Replacing strings/ replacing numbers and letters
    By Insert Name in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2015, 01:15 PM
  3. Replacing Numbers from One Sheet to Another
    By wwilli41 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2013, 06:46 PM
  4. Replacing a UPC Number without Modifying a Model Number
    By SpyderPB6 in forum Excel General
    Replies: 4
    Last Post: 07-17-2012, 03:15 PM
  5. Excel 2007 : Replacing Words w/ Numbers
    By gt5hz in forum Excel General
    Replies: 3
    Last Post: 04-14-2010, 02:50 PM
  6. using treater than and replacing numbers
    By mja in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-23-2005, 02:06 PM
  7. Replies: 1
    Last Post: 02-08-2005, 03:06 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