Dynamic Named Ranges with dynamic starting points?

kjlorfeld

New Member
Joined
Nov 29, 2005
Messages
22
I have a table with two columns - departments and employees. There are multiple departments, and multiple employees within each department. For example:

Dept. Employee
1 Bob
1 Mike
1 Sally
2 Tom
2 Karen
3 Joe
4 Katie

I'd like to create a named range (to use in data validation) that is driven off of whatever department a user selects. If they select department 1, the range would be B2:B4, if they select department 3, the range would be B7:B7. I've seen dynamic named ranges using offset (and maybe index?) but it seems they all rely on a static starting point. Any thoughts on how I might be able to do this?

Thanks!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi

Would you be able to afford a helper column ? If so i've got a solution..

1. Assume your data is from A1:B8 and the criteria cell is C1 (where you need to enter your dept id)

2. paste the below formula in cell D1.

=IFERROR(INDEX($B$1:$B$8,SMALL(IF($A$1:$A$8=$C$1,ROW($A$1:$A$8),""),ROW(A1)),0),"")

and drag it till D8.

3. Now enter any dept id in cell C1 and you can see the column D will show the data only corresponding to the dept id given.

4. Now select this range (D1:D8) in data validation.

Thanks,
Anand
 
Upvote 0
Hi,

Hopefully this will do what you need...............

Say this is your data


Excel 2010
AB
31Bob
41Mike
51Sally
62Paul
72Peter
83Fred
9
Sheet1



Use this formula in another cell (For my purpose it's in G7)
=ADDRESS(MATCH($E$4,$A$1:$A$8,0),1)

E4 will contain the dept. number

Then..........In Name manager add this formula to a name

=OFFSET(INDIRECT(Sheet1!G7),0,1,COUNTIF(Sheet1!$A$3:$A$8,Sheet1!$E$4))

The G7 relates to the first instruction........

Then just do a Data validation --> List and use the name range that you used for the offset.............

I've got this working and it works fine...........

Regards,
Chris
 
Upvote 0
try

=OFFSET($B$1,MATCH($D$1,$A$2:$A$8,0),0,COUNTIF($A$2:$A$8,$D$1),1)

D1 is the cell to enter the Department #.
B1 is the HEADER for column B (employee)
A2:A8 are all the departments.
 
Upvote 0
I have a table with two columns - departments and employees. There are multiple departments, and multiple employees within each department. For example:

Dept. Employee
1 Bob
1 Mike
1 Sally
2 Tom
2 Karen
3 Joe
4 Katie

I'd like to create a named range (to use in data validation) that is driven off of whatever department a user selects. If they select department 1, the range would be B2:B4, if they select department 3, the range would be B7:B7. I've seen dynamic named ranges using offset (and maybe index?) but it seems they all rely on a static starting point. Any thoughts on how I might be able to do this?

Thanks!
what's your ultimate use of that range?

I think there should be some better formulas to achieve that aim, which you do not need to refer that specific range
 
Upvote 0

Forum statistics

Threads
1,214,638
Messages
6,120,674
Members
448,977
Latest member
moonlight6

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