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.
 
Before I posted yesterday I started looking for the solution and everything looked so complicated, and frankly, possibly beyond me. That's why I started thinking about PowerQuery.

However, my feeling is that leaving PowerQuery out of the picture until it is really necessary for analyzing things is better. (It always seems to make the workbooks go slower. (I don't have any factual justification for that, and if I'm wrong someone please tell me.)

So, Yes. If you are willing to give the formulas way a try, I'd certainly appreciate that.
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
My columns will not always have data in every cell.
Could you clarify ta couple of things first?

Will the empty cells always be at the bottom of the list, of could there be empty cells in the middle? i.e. data in C2:C4 and C6:C10 but C5 empty.

Are the empty cells really empty, or do they contain formulas that show blanks?

Having re-read your original post, I think that Peter's suggestion in post 8 will be the best method for you to use, or perhaps a variation of it to allow for the blanks, but that would depend on the outcome of the points that I have asked you to clarify.
 
Upvote 0
The empty cells could occur anywhere in the column, not just the beginning or the end. It could be a gap of one cell or many
I had not thought about formulas. There re some such columns in a few of the tables I am working. However, they are at the end of the tables and I have added them for the purpose of pivot tables that interpret some of the data, or for resetting some checkboxes to false when the data is recalled to the form to be viewed. They (to a high degree of certainly) would not be columns I would use in the way we are talking about. So I think it best to go ahead assuming no cells with formulas are involved at this time.
Does that Help?
 
Upvote 0
See if this would suffice.

  1. For any columns you might want to use for Data validation, add an extra column to the table and use identical headings but append "DV" to each heading.

  2. Add the formulas shown to the top cell in each of these additional columns and the results should spill down the column.

  3. These additional columns can now be hidden if you want.

  4. Add the Data validation as shown. Note that I have assumed the main columns are not formulas. However, that may not be the case. If formulas are or could be involved in the main data area (columns B:E below) then use this formula in the DV for cell D16 instead of the one shown below the mini-sheet.

    =OFFSET(INDIRECT("Table1["&B13&"DV]"),0,0,COUNTIF(INDIRECT("Table1["&B13&"DV]"),"?*")+COUNT(INDIRECT("Table1["&B13&"DV]")))

Me22 2020-03-08 1.xlsm
ABCDEFGHIJ
1NumberNameCityDivisionNumberDVNameDVCityDVDivisionDV
210Name 1City 110Name 1City 1Div 4
311Name 2City 211Name 2City 2Div 5
41212Name 5City 4Div 6
513City 4Div 413Name 6City 6Div 7
614Name 5Div 514 City 7 
715Name 6City 6Div 615   
816City 7Div 716   
9
10
11
12
13City
14
15
16
17
DV Lists
Cell Formulas
RangeFormula
F2:F8F2=IFERROR(INDEX([Number],AGGREGATE(15,6,(ROW([Number])-ROW(Table1[#Headers]))/([Number]<>""),ROW()-ROW(Table1[#Headers]))),"")
G2:G8G2=IFERROR(INDEX([Name],AGGREGATE(15,6,(ROW([Name])-ROW(Table1[#Headers]))/([Name]<>""),ROW()-ROW(Table1[#Headers]))),"")
H2:H8H2=IFERROR(INDEX([City],AGGREGATE(15,6,(ROW([City])-ROW(Table1[#Headers]))/([City]<>""),ROW()-ROW(Table1[#Headers]))),"")
I2:I8I2=IFERROR(INDEX([Division],AGGREGATE(15,6,(ROW([Division])-ROW(Table1[#Headers]))/([Division]<>""),ROW()-ROW(Table1[#Headers]))),"")
Cells with Data Validation
CellAllowCriteria
D16List=OFFSET(INDIRECT("Table1["&B13&"DV]"),0,0,COUNTA(INDIRECT("Table1["&B13&"]")))
B13List=$B$1:$E$1



1583626042152.png
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,044
Messages
6,122,827
Members
449,096
Latest member
Erald

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