简体   繁体   中英

Excel: Use a string instead of cell range for data validation list with IF conditional?

I'm trying to set up a Data Validation cell in a spreadsheet for one of our clients to use.

Basically, the end result should be a dropdown menu if the first cell in the row (A#) has a value, and NULL or "" otherwise.

I can achieve this using a reference to cells, such as:

IF(A1<>"",AA1:AA3,AA4)    --> AA1:AA3 contain our three selections, AA4 is blank

The reason I would like this to be 'self contained' is because we are going to programmatically convert the spreadsheet to CSV, and import values into our SQL database. I don't want to write exception code for the unwanted values if I don't have to ^_^ one more thing to break...

Ideally, it would be something like this:

IF(A1<>"","Telephone Presenter (Partial Rights),Attendee,Presenter (Full Rights)","")

Is what I'm asking for achievable, or should I consider the exception code or maybe writing my own program for them to input the data into?

EDIT:
Cell A1 contains an individual's name (EG John Doe), the DV occurs on D1, where I want "If a name is specified, offer roles to assign, otherwise, offer only a blank cell."

This should work if you're just looking to flag the cell in the event of a data integrity error.

=IF(OR(A1="Telephone Presenter (Partial Rights)",A1="Attendee",A1="Presenter (Full Rights)",A1=""),"","Error")

You could also consider using conditional formatting on those input cells (for example highlight red when bad data is entered), or look into writing some VBA code for more robust data integrity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM