+ Reply to Thread
Results 1 to 26 of 26

Add Second Function To Validation Formula

  1. #1
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Question Add Second Function To Validation Formula

    I'm trying to get a validation formula to work with Cell I2. It needs to check the number entered to make sure there is no dash, which is working with this formula:

    =IF(ISNUMBER(SEARCH("-",I2)),FALSE, TRUE)

    I'm trying to expand that formula to also check if there's a dash in Cell C2, and not allow the value to be entered in Cell I2 if there is a value without one.

    So basically, it needs to make sure there is no dash in the value entered into Cell I2, and that if Cell C2 has a value, it includes a dash. (If there is no value in Cell C2, then no dash doesn't matter.)

    How would I be able to make this work?
    Last edited by Leith Ross; 04-03-2012 at 12:12 PM. Reason: Removed Quote Tag around the formula
    There is so much good in the worst of us,
    And so much bad in the best of us,
    That it hardly behooves any of us
    To talk about the rest of us.

  2. #2
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Add Second Function To Validation Formula

    Try this out

    =IF(ISNUMBER(SEARCH("-",I2)),FALSE,IF(OR(ISNUMBER(SEARCH("-",C2)),C2=""),TRUE,FALSE))
    If you liked my solution, please click on the Star -- to add to my reputation

    If your issue as been resolved, please clearly state so and mark the thread as [SOLVED] using the thread tools just above the first post.

  3. #3
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    That is fantastic, thank you so much!

  4. #4
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    Would you have any idea how to modify that formula so I could also use it in Cell I9 to do this:

    Only allow an entry containing a '-2', and only if Cell C1 contains a '-1'?

  5. #5
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Add Second Function To Validation Formula

    =if(isnumber(search("-2",i2)),false,if(or(isnumber(search("-1",c2)),c2=""),true,false))

  6. #6
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    That doesn't seem to be doing it - I changed it to this:

    =IF(ISNUMBER(SEARCH("-2",I9)),FALSE,IF(OR(ISNUMBER(SEARCH("-1",C2)),C2=""),TRUE,FALSE))

    ..because I9 is the cell I'm using it in, but I'm able to enter any value except for a '-2' value. The checking for '-1' in Cell C2 works, though...

  7. #7
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Add Second Function To Validation Formula

    Try this

    =IF(ISNUMBER(SEARCH("-2",I9)),IF(OR(ISNUMBER(SEARCH("-1",C1)),C1=""),TRUE,FALSE),FALSE)

  8. #8
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    Okay, upon changing the C1's to C2's in the formula, that works when Cell C2 contains a value. But it allows Cell I9 to contain anything when C2 is empty.

  9. #9
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Add Second Function To Validation Formula

    Give this a shot... if not could you please attach a sample book with a couple conditions to test?

    =IF(OR(ISNUMBER(SEARCH("-1",C1)),C1=""),IF(ISNUMBER(SEARCH("-2",I9)),TRUE,FALSE),FALSE)

  10. #10
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    Yeah, that's still not working, and I think you're right, we may not be understanding each other fully here.

    Please feel free to check the attachment, that should help.
    Attached Files Attached Files

  11. #11
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Add Second Function To Validation Formula

    i was allowing for a blank cell in C2, try this

    IF(ISNUMBER(SEARCH("-1",C2)),IF(ISNUMBER(SEARCH("-2",I9)),TRUE,FALSE),FALSE)

  12. #12
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    Hmm, almost there, but I'm still having one more issue - try entering 12345-1 into Cell C2, and then enter 12345-2 into Cell I9.

  13. #13
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Add Second Function To Validation Formula

    should that not be allowed?

  14. #14
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    Yes, that should be allowed. Cell I9 may only contain any value (ending with a -2, of course) if Cell C2 has data with a -1.

  15. #15
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Add Second Function To Validation Formula

    That is what it is doing, it seems to be working for me.

  16. #16
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    So when you enter 12345-2 into Cell I9, it lets you do it?

  17. #17
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Add Second Function To Validation Formula

    yes, are you using the last formula i provided?

    =IF(ISNUMBER(SEARCH("-1",C2)),IF(ISNUMBER(SEARCH("-2",I9)),TRUE,FALSE),FALSE)

  18. #18
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    I thought I was, but after pasting your last formula into Data Validation, that part is working. Are you able to enter 12345-2 into Cell I9 when Cell C2 is empty? Because I am.. and I shouldn't be able to.

  19. #19
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Add Second Function To Validation Formula

    Try this..

    =IF(AND(ISNUMBER(SEARCH("-1",C2)),C2<>""),IF(ISNUMBER(SEARCH("-2",I9)),TRUE,FALSE),FALSE)

  20. #20
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    I can still enter anything I like into Cell I9 when Cell C2 is empty.

  21. #21
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    Which is not a good thing.

  22. #22
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Add Second Function To Validation Formula

    make sure you have "Ignore Blank" unchecked

  23. #23
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    That did it! Thank you very much. One last thought - do you know if there's any way to specify that the value must end with a -2 only, and not a -22 or anything like that? In my case, it's highly unlikely that will happen, but I'm just wondering if there's some kind of formula code for that.

  24. #24
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Add Second Function To Validation Formula

    yes, you just need to modify your formula to use right, instead of search.

    something like this (note i changed the formula up too)

    =IF(AND(RIGHT(C2,2)="-1",RIGHT(I9,2)="-2"),TRUE,FALSE)

  25. #25
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Add Second Function To Validation Formula

    That is lovely, thank you so much!

  26. #26
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Add Second Function To Validation Formula

    no problem at all

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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