+ Reply to Thread
Results 1 to 6 of 6

Condition if variable different than x or y

  1. #1
    Registered User
    Join Date
    05-07-2015
    Location
    Angouleme, France
    MS-Off Ver
    2013
    Posts
    48

    Condition if variable different than x or y

    Hello !

    Today I have a simple question.

    I have a cell that I want to contain "C" or "NC". When I press my button control, I want a MsgBox to pop up if it's different.
    I tried this :
    Please Login or Register  to view this content.
    Of course, it doesn't work, or else I wouldn't be there

    Is there a way to do it like so, or do I have to write strContent <> "C" and strContent <> "NC" ?

    Thank you !

  2. #2
    Registered User
    Join Date
    10-11-2011
    Location
    FB Republic
    MS-Off Ver
    2016
    Posts
    36

    Re: Condition if variable different than x or y

    Hi.
    try this:
    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Condition if variable different than x or y

    Or a change event

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-07-2015
    Location
    Angouleme, France
    MS-Off Ver
    2013
    Posts
    48

    Re: Condition if variable different than x or y

    @mancubus : Yeah, using "with" could save me some space, thanks.
    @Vraag en antwoord : I don't think I need the change event. Plus, if I write If Target <> "C" Or Target <> "NC" It will always be true, since the value can't be "C" and "NC" at the same time. Schrödinger would disagree with me, though

  5. #5
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Condition if variable different than x or y

    oops must be And

    With a change event you don't need a button.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    05-07-2015
    Location
    Angouleme, France
    MS-Off Ver
    2013
    Posts
    48

    Re: Condition if variable different than x or y

    I figured that ahah

    Yes I know how it works, but the check has to be done just before the validation so I tell you I don't need it :P But thank you anyway !

+ 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. Macro code using IF case with variable inputs for logical test condition
    By m2krishnan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-16-2013, 10:59 PM
  2. [SOLVED] Max value in table IF variable condition met
    By FrankHouston in forum Excel General
    Replies: 7
    Last Post: 07-17-2012, 10:11 PM
  3. multi condition format? lookup and date condition valid for.
    By D_Rennie in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-13-2009, 11:37 AM
  4. COUNTIFS with a variable condition
    By cjsec9 in forum Excel General
    Replies: 2
    Last Post: 04-01-2009, 02:51 PM
  5. Array formula with variable condition
    By BRISBANEBOB in forum Excel General
    Replies: 9
    Last Post: 01-07-2009, 05:33 PM

Tags for this Thread

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