Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Data validation drop-down list based on criteria in the row?

$
0
0

I want a data validation drop-down list that populates based on the value in another column in the same row. I've found a lot of great examples with multiple dependent drop-down lists, but unfortunately I don't think those will work in this case. Instead of a dynamic list based on a single fixed cell, I want a whole column of these, each based on its own row and independent of the others.

Here's the setup:

SPELLS KNOWN

"Spells Known" is the data source, containing Level and Name columns. A given Name can appear multiple times, corresponding to different Levels. (It's also important for each Level to have its own unique list, because the table contains additional columns with level-specific values, e.g. a Level 3 Heal has different values than a Level 1 Heal.)

LevelName
1Heal
1Magic Missile
1Sanctuary
2Dispel Magic
2Heal
2Resist Energy
3Heal
3Magic Missile

SPELLS PREPARED

"Spells Prepared" is the user-facing table. The idea is to specify the Level and then use a drop-down in the Name column to select from the values listed for that Level.

LevelName (select from drop-down)
1{Heal, Magic Missile, Sanctuary}
2{Dispel Magic, Heal, Resist Energy}
3{Heal, Magic Missile}

And here's what I've tried:

Since it's not possible to get a drop-down when using "Custom formula is" in Data Validation, I tried to combine the values into a comma-delimited list in a single "helper" cell on the same row as the drop-down, using the following:

=ARRAYFORMULA(TEXTJOIN(",",TRUE,IF(SpellsPrepared_Level=SpellsKnown_Level,SpellsKnown_Name,"")))

The problem is that data validation treats this output as a single string—that is, the drop-down has only one option: "Heal,Magic Missile,Sanctuary", instead of recognizing the comma delimiter like it would if you had entered the same string as a list directly into the Data Validation window, and thereby treating the list as three items.

It seems like the next thing to try would be to create a new sheet where Column A equals SpellsPrepared_Level, and Columns B, C, and so on each contain a single SpellsKnown_Name value in the list based on that Level. Then, data validation could use a "List from range" and build the drop-down list from those values for each row.

But that doesn't seem terribly elegant. Is there a more efficient way to accomplish this? Let me know if having the actual sheet would be more helpful.


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>