+ Reply to Thread
Results 1 to 17 of 17

data validation on multiple cells

  1. #1
    Registered User
    Join Date
    02-03-2010
    Location
    Seol, Korea
    MS-Off Ver
    Excel 2003
    Posts
    12

    data validation on multiple cells

    Hi team:

    Im new to this forum & relatively new to complicated excel problems.

    Scenario is:

    In sheet1, I have column A & B which has values like:

    10 1000
    11 1001
    12 1002

    In sheet 2 of the same workbook, I want to place a restriction that the user should only be able to enter the above values in the same combination like:

    10 1000 -- is valid
    10 1001 -- is invalid
    11 1001 -- is valid
    11 1002 -- is invalid

    i tried using the data>validations & was successful in restricting the values to one column. but how to restrict the values in combination?

    Thanks.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: data validation on multiple cells

    Hi cherry sharma,

    welcome to the forum.

    On sheet1, select your list of validation values, i.e A1 to B3 in your example and assign this range a name, e.g. valList

    On sheet 2, enter a value in cell A1
    In cell B1, enter this custom data validation formula

    =B1=VLOOKUP(A1,valList,2,FALSE)

    Now you can only enter a value into B1 if it can be matched in the valList table in Sheet1

    hth

  3. #3
    Registered User
    Join Date
    02-03-2010
    Location
    Seol, Korea
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: data validation on multiple cells

    thanks for your help teylyn

    but if i enter the value in B1 first, A1 allows me to enter any value.

    i applied your logic (data validation) on A1, but then the cell does not allow me to enter any value.

    can you pls advise?

    thank you.

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: data validation on multiple cells

    OK, I wrongly assumed that you would first type a value like 10 or 11 or 12 in column A of Sheet2 before you tackled column B. But this can also be done.

    In Sheet1, select the values in column B and give them a range name, like valListB.

    Now, in Sheet2, the data validation custom formula for A1 is

    =AND(COUNT(A1:B1)=2,A1=INDEX(valList,MATCH(B1,valListB,0),1))

    and the data validation custom formula for B1 is

    =AND(COUNT(A1:B1)=2,B1=VLOOKUP(A1,valList,2,FALSE))

    So, when you enter only one value, in either A or B, you can enter pretty much whatever you like, but as soon as you enter the second value in the same row, you'll get an error message if the two values don't match up with the values as they are defined per row on Sheet1.

    Will that do you?

  5. #5
    Registered User
    Join Date
    02-03-2010
    Location
    Seol, Korea
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: data validation on multiple cells

    teylyn, thanks a lot. the above logic works great!
    im sorry for not pointing this out before. but if i enter the formula for the below data set, it does'nt work.
    A B
    10 1000
    10 1001
    30 1002
    40 1003

    notice, 10 is repeated on the 2nd row as well. thats the reason why this fails.
    thanks again for looking at it.

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: data validation on multiple cells

    You have to copy the data validation down to the cells below. Set up the data validation in cells A1 and B1, then copy cells A1 and B1, select the cells A2 to B100 (or whatever) and click Edit - Paste Special - Validation.

  7. #7
    Registered User
    Join Date
    02-03-2010
    Location
    Seol, Korea
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: data validation on multiple cells

    im sorry for not explaining it properly enough.
    my data set will look as follows (with some repetitive values) :
    A B
    10 1000
    10 1001
    30 1002
    40 1003
    50 1003
    60 1005

    i want to restrict the user from entering any other combination other than the above

    A B
    10 1000 -- valid
    10 1002 -- invalid
    10 1001 -- valid

    thank you.

  8. #8
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: data validation on multiple cells

    That won't wash.

    You're changing the goal posts in the middle of the game. In your first post you clearly said

    10 1000
    11 1001
    12 1002
    and

    10 1000 -- is valid
    10 1001 -- is invalid
    11 1001 -- is valid
    11 1002 -- is invalid
    and now you say

    10 1000 -- valid
    10 1002 -- invalid
    10 1001 -- valid
    That's quite a contradiction, don't you think? It would really help to specify the full requirements up front, instead of sending people off on a wild goose chase.

    If it can be done, I'm out of it for the moment. Maybe someone else can take over. To me that looks like a concept that requires array formulae, which will not be possible in data validation custom formula settings.

    going back into my cave ....
    Last edited by teylyn; 02-03-2010 at 08:41 AM.

  9. #9
    Registered User
    Join Date
    02-03-2010
    Location
    Seol, Korea
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: data validation on multiple cells

    Honestly, my intention was never to waste your time by misguiding. I take the blame for posting incomplete requirements & I apologize. If you wish, you can ignore my last post by not answering. Frankly I never thought I would reach this far .... Thanks again & sorry for wasting your time.
    Last edited by cherry.sharma@aol.in; 02-03-2010 at 01:06 PM.

  10. #10
    Registered User
    Join Date
    02-03-2010
    Location
    Seol, Korea
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: data validation on multiple cells

    hello
    A B C
    10 1000 101000
    10 1001 101001
    30 1002 301002
    40 1002 401002
    40 1004 401004

    i've named column C as valListC. i concatenated the value of the 1st two columns in the 3 rd column, which will be always unique. & then i tried

    B1=VLOOKUP(concatenate(a1,b1),valListC,2,FALSE)

    when i try to enter 1000 in cell B1, it should allow. but it restricts the entry of any value to this column.

    anyone else with ideas??

  11. #11
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: data validation on multiple cells

    Hah!
    back out of my cave!

    Good idea with the concatenation! The result is a number, though, not text in valListC and you only have one column in valListC, so you can not use 2 as the third argument of Vlookup. Try this as your validation custom formula on Sheet2 with valListC on Sheet1:

    =VALUE(CONCATENATE(A1,B1))=VLOOKUP(VALUE(CONCATENATE(A1,B1)),valListC,1,FALSE)

  12. #12
    Registered User
    Join Date
    02-03-2010
    Location
    Seol, Korea
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: data validation on multiple cells

    thank you very much teylyn. this meets my requirement perfectly well.

    on the side note, if i copy & paste the value on this "data validated" cell from another excel sheet, the value is not validated. how can i make it to work in copy/paste situations as well?

    eventually my aim is to prohibit the user from entering anything other than the combinations i define. i thought this would work in copy/paste situations as well. but i was wrong. anything that im missing?

  13. #13
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: data validation on multiple cells

    copy the cell with the data validation. click the target cell(s) and then Edit - Paste Special - Validation- OK

    You may want to post a workbook with your original data layout,so we can assure that the cell references are anchored to the correct cells.

    cheers

  14. #14
    Registered User
    Join Date
    02-03-2010
    Location
    Seol, Korea
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: data validation on multiple cells

    teylyn, when i copy contents from say Book 2 (which does not have any "data validation") into Book 1 (which has validation) the contents gets copied, over riding any validation you put.

    i want to preserve the validation on the cell, when i paste values from any application.
    Last edited by cherry.sharma@aol.in; 02-04-2010 at 07:47 AM.

  15. #15
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: data validation on multiple cells

    cherry,

    that's one of the drawbacks of data validation. If you copy anything into a cell with data validation, the data validation will be overwritten by the new content and format/validation. Even if you just copy the values, the data will not be validated.

    Data validation is designed to reduce errors during manual data entry, cell by cell. It is not designed to verify data that gets into cells any other way. You would need VBA code to check for that.

  16. #16
    Registered User
    Join Date
    02-03-2010
    Location
    Seol, Korea
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: data validation on multiple cells

    thanks for your quick response. i read the same on one of the websites, but was not sure if it was true, hence the question.

    should i create a new topic for the VBA code? im sure im not the first to be hit by this issue. there may be codes around, which im trying to search. if you have any pointers / links to any workarounds, please do let me know. thanks for all your help! its been a good learning!

  17. #17
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: data validation on multiple cells

    should i create a new topic for the VBA code?
    Yes please. Feel free to link to this thread if you feel it is useful.

    The forum search is hopeless. Try a site search in google instead, like

    "your search keywords" site:excelforum.com

+ 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