+ Reply to Thread
Results 1 to 6 of 6

Changing a positive or negative value based on the input's suffix, then removing suffix

  1. #1
    Registered User
    Join Date
    01-05-2014
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Changing a positive or negative value based on the input's suffix, then removing suffix

    Hi, first time posting so I hope this is in the right place pertaining to coding

    I need to change the format of a coordinate, by removing the suffix ("125.00S", where S is for South) and then changing positive/negative value based on said removed suffix (N would keep the value as positive, S would change the value to negative).

    in short
    Input cell at A1 would read: 125.00S
    I want Output cell at A2 to read: -125.00

    I know I can remove the S from the string by using =Left(A1,LEN(A1)-1)
    but I don't know how to use that suffix to change the number to a negative or positive value. Ideally, I would like to do this in one cell without having to use other cells.

    thanks in advance.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Changing a positive or negative value based on the input's suffix, then removing suffi

    =IF(RIGHT(A1)="S",SUBSTITUTE(A1,"S","")*-1,SUBSTITUTE(A1,"N","")*1)
    then format cell to 2 decimal places
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    01-05-2014
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Cool Re: Changing a positive or negative value based on the input's suffix, then removing suffi

    well first off, that was super fast!!

    second off, that was a completely different approach than what I had...

    Thanks for both of those of things! very greatly appreciated

  4. #4
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Changing a positive or negative value based on the input's suffix, then removing suffi

    Couple of other ways

    =IF(RIGHT(A1)="S",-1,1)*SUBSTITUTE(A1,RIGHT(A1),"")
    or
    =IF(RIGHT(A1)="S",-1,1)*LEFT(A1,LEN(A1)-1)
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  5. #5
    Registered User
    Join Date
    01-05-2014
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Changing a positive or negative value based on the input's suffix, then removing suffi

    heh.. multiple ways to do the same thing... thanks Ace_XL

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Changing a positive or negative value based on the input's suffix, then removing suffi

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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: 4
    Last Post: 11-29-2011, 09:05 AM
  2. question about suffix
    By prahaladje in forum Excel General
    Replies: 1
    Last Post: 09-24-2010, 06:50 AM
  3. Autofilter based on suffix value
    By jaslake in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 04-18-2010, 09:15 AM
  4. [SOLVED] How do I had a suffix to a cell i.e. -1,-2,-3?
    By controller_woman in forum Excel General
    Replies: 1
    Last Post: 07-12-2005, 01:05 PM
  5. [SOLVED] I'd like to add a suffix...
    By Dr. Darrell in forum Excel General
    Replies: 4
    Last Post: 06-18-2005, 12:05 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