Change formula in Data Validation based on cell selection

Me22

New Member
Joined
Feb 17, 2020
Messages
19
Office Version
  1. 2010
Platform
  1. Windows
I have need to change a formula in a Data Validation list based on the selection in another cell.

As an example, I have a table setup that has 4 columns and 8 rows including headers:

1582044195078.png


The Data Validation is part of the selection process to pull a record from an array. The dropdown list is generated from the formula in the Name "Select" and currently is:
OFFSET(!$C$1,1,0,COUNTA(Sheet1!$C:$C)-1,1).

This give a dropdown of Column C and allows me to select a record by name.

I also have a Data Validation list in the Search By which generates it's list from the Name "Search_By" which references the table headers.

I want to alter the OFFSET formula for "Select" in the Data Validation when I make a selection in the "Search By" dropdown. So if I select "City" in stead of "Name", the formula would be:
OFFSET(!$D$1,1,0,COUNTA(Sheet1!$D:$D)-1,1).

I've tried referring to the Cell "Search By" is in, B13, but no go. I've also tried to use INDIRECT in various ways, with no success.

So how do I alter that formula in Data Validation through the use of a dropdown selection in a cell? Can't figure it out.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
As you have a fairly simple table, using an index formula ' might' work, but the known method involves named ranges and indirect references.

Try

=INDEX(Sheet1!$B$2:$E$8,0,MATCH(Sheet1!$B$13,Sheet1!$B$1:$E$1,0))

If that doesn't work then I suggest looking at some of the in depth articles that explain how to set up dependent validation lists, such as the one that @mumps has suggested, or the one here,
 
Upvote 0
Ah, I should have mentioned that the actual table has 112 columns and 200 rows (at the moment-- added to regularly). I don't know that I will ever need to search by each of the 40 headers, but that flexibility would be nice.
 
Upvote 0
Ah, I should have mentioned that the actual table has 112 columns and 200 rows (at the moment-- added to regularly). I don't know that I will ever need to search by each of the 40 headers, but that flexibility would be nice.
The 40 headers that matter most I mean.
 
Upvote 0
A different method, assuming that column B contains only numbers below the header and that all columns will be equal in length.

=OFFSET(Sheet1!$B$2,,MATCH(Sheet1!$B$13,Sheet1!$1:$1,0)-COLUMN($B$2),MATCH(1e+100,Sheet1!$B:$B),1)

I personally prefer to use index rather than offset, but it can't be used with data validation if the size of the source list is variable.
 
Upvote 0
Hello again. So I have gone through the options given and have several different solutions that can work. Just have to settle on one.
Thanks so much for the help. I have another issue now but will go to a new thread.
 
Upvote 0
Could this alternative approach be any use to you?

  1. Turn the data table into a formal Excel table by selecting it, including headings, then Insert ribbon tab -> Table (may be slightly different in Excel 2010 as I can't remember)

    1582173237569.png


  2. For you DV in 'Select' no need for a name definition, just use this in the DV List dialog

    1582173739851.png
If you change the value in the B13 drop-down, the 'Select' drop-down changes to suit.

1582173880111.png
 
Last edited:
Upvote 0
Thank you all for the feedback and direction. I have to do a bit of a rethink on this it seems. My columns will not always have data in every cell. That is complicating it more. I'm thinking I may have to use powerquery to generate lists to make it easier. I'll post when/if I work out how to go forward.
 
Upvote 0
If you mean that there could be intermittent gaps then it can still be done with formulas, but it can get messy.

To do it and keep the lists tidy, you would need to duplicate every list with formulas to filter out the blanks, then use the formula generated lists to populate the dropdowns.

If this is something you want to look into then I'll put an example together sometime over the weekend, unless Peter does it first.
 
Upvote 0

Forum statistics

Threads
1,215,563
Messages
6,125,565
Members
449,237
Latest member
Chase S

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top