+ Reply to Thread
Results 1 to 4 of 4

Don't change the current value if a condition is met, change if condition is not met

  1. #1
    Registered User
    Join Date
    05-31-2012
    Location
    Paris
    MS-Off Ver
    Excel 2007
    Posts
    48

    Don't change the current value if a condition is met, change if condition is not met

    Hello,

    I have this kind of formula :

    IF(A1=0;VALUE 1;IF(A1=1;VALUE 2;XXX)) and I would like that XXX (the ELSE condition) should maintain the previous current value, if A1 <> 0 or 1 :

    - VALUE 1 if in the previous test, A1 was 0
    - VALUE 2 if in the previous test, A1 was 1

    Hope my question is clear.
    Thanks for the kind help in advance.
    Frederic

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,761

    Re: Don't change the current value if a condition is met, change if condition is not met

    Then you will need this:

    =IF(A1=0;VALUE 1;IF(A1=1;VALUE 2;A1))
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Don't change the current value if a condition is met, change if condition is not met

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

    For example
    if the previous value = 5
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    If previous formula was =A2+A3 then
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,617

    Re: Don't change the current value if a condition is met, change if condition is not met

    Hi,
    First I thought that, as AliGW wrote:
    =IF(A1=0,VALUE 1,IF(A1=1,VALUE 2,A1))
    is what you look for, but then I started wondering what do you mean by "previous current value".

    Let's say this formula is in B1, and we have the following sequence:

    First you write 1 in A1 so B1 becomes VALUE 2
    Then you write 0 in A1, so B1 becomes VALUE 1
    And then you write 3 in A1 so B1 "recognizes" it's neither 0 nor 1 and remais unchanged as VALUE 1

    If it's what you look for, then I'd rather see not formula in B1, but macro (event handler for Change event) reacting to changes in A1.
    Best Regards,

    Kaper

+ 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. Change formula if a condition met
    By tsakta13ole in forum Excel General
    Replies: 1
    Last Post: 07-03-2015, 07:04 AM
  2. Condition for Tab Colour Change
    By carney05 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2013, 04:44 PM
  3. Change colour of bar if condition is met
    By DeeBee in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 10-21-2013, 11:07 AM
  4. Condition Formatting: Change color when month change (oct = red, Nov = blue)
    By Flyinace2000 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-28-2012, 12:20 PM
  5. auto change cell formula on condition of worksheet change in other cells
    By futurejock in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-01-2009, 12:11 AM
  6. Replies: 7
    Last Post: 04-26-2006, 08:50 PM
  7. change shape by condition
    By Libramanuk in forum Excel General
    Replies: 6
    Last Post: 03-21-2006, 10:50 AM

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