Lookup over a range and return 2 columns

jl2509

Board Regular
Joined
Oct 30, 2015
Messages
198
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Another conundrum which I need help with if possible.

The image below shows a list of departments and the number of purchase orders they have open, although the list is greater than the 3 sample departments and this is just a sample of the data.
On a separate sheet "Dashboard" I have a drop down box in Cell M6, with the department names listed.

By selecting the drop down box and lets say "Mechanical Dept" is selected, then the names and # POs > 0 will be added below the drop down box from cell M9 as shown in the second image?

Many thanks

1704992343039.png
1704992698094.png
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
You should combine all those department tables. Add another column called department in that single table. Here is a simple answer

Book4
ABCDEFGHIJ
1DepartmentNamePOsDept ListChoose Department
2ArtHailee Prue0ArtMechanical
3ArtVeronica Bertina0Mechanical
4ArtTrixie Terrance0Physics
5MechanicalHenry Karl1DepartmentNamePOs
6MechanicalPrince Mary Lou1MechanicalHenry Karl1
7MechanicalStacey Briggs0MechanicalPrince Mary Lou1
8PhysicsWrenley Rue10
9PhysicsIzaiah Tiana10
10PhysicsBette Blaire10
11PhysicsTabitha Cash00
120
130
140
150
160
170
Sheet2
Cell Formulas
RangeFormula
F2:F4F2=SORT(UNIQUE(A2:A11))
H6:I7H6=FILTER(A2:B11,(A2:A11=H2)*(C2:C11<>0),"")
J6:J17J6=SUMIFS($C$2:$C$11,$A$2:$A$11,$H$2,$B$2:$B$11,I6)
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
H2List=F2#
 
Upvote 0
Thanks for the response Jeffrey
Unfortunately, I cannot put them all in one column as they are imported from SQL data from separate external sheets by department

If this is not possible how I initially proposed, I guess I will just need to look at alternative methods but its not my preference.
 
Upvote 0
Thanks for the response Jeffrey
Unfortunately, I cannot put them all in one column as they are imported from SQL data from separate external sheets by department

If this is not possible how I initially proposed, I guess I will just need to look at alternative methods but its not my preference.
You could use the new FILTER function to get what you want. The only issue is that you do not know which of the various ranges to apply it to. So it would work fine if creating that formula manually each time, but I don't know if you are going to be able to create one dynamic formula that would work for any instance.

I do not know if you are going to be able to do what you want without using VBA. You can only do so much with poorly formatted/structured data, without having to manually interact with it first.
If you decide to go the VBA route, I would probably recommend have VBA do what Jeff proposed, and copy all your data into one long list. And then you can use the formulas he proposed.
 
Upvote 0
It will get you better/faster responses in the future if you can provide your sample data in a form that can be easily copied for testing, rather than an image. I suggest that you investigate XL2BB

Try something like this. Adjust ranges if required.

jl2509.xlsm
BCDEFGHI
1
2
3
4Art DeptMechanical DeptPhysics Dept
5
6
7Po'sName Po'sName Po'sName
80a1f1p
90b1g1q
100c0h1r
111d1i0s
121e0j0t
131k0u
141l1v
151m0w
160n
171o
18
Sheet1


jl2509.xlsm
MN
6Mechanical Dept
7
8Open PosName
91f
101g
111i
121k
131l
141m
151o
16
17
Dashboard
Cell Formulas
RangeFormula
M9:N15M9=LET(c,MATCH(M6,Sheet1!B4:X4,0),dpt,CHOOSECOLS(Sheet1!B8:X100,c,c+1),FILTER(dpt,TAKE(dpt,,1)=1,""))
Dynamic array formulas.
 
Upvote 0
Solution
I stand corrected! It looks like Peter may have managed to come up with a whopper of a formula that will seem to work on your data structure!
 
Upvote 0
Thanks for the feedback Peter. Works a treat
BTW, I cannot install XL2BB due to hardware restrictions
 
Upvote 0
Note: When marking a post as the solution, please mark the original post actually containing the solution, and not your own post acknowledging that some other post is the solution.
I have updated this thread for you.
 
Upvote 0
Thanks for the feedback Peter. Works a treat
You're welcome. Thanks for the follow-up. :)

BTW, I cannot install XL2BB due to hardware restrictions
In future, I suggest that you mention this in the first post so that we don't keep asking. ;)

Provided the data is not too big, instead you can simply copy/paste from your worksheet like below and tell us what the range is (mine is B4:I17). It isn't quite as good as XL2BB but at least we can copy from that and paste into our worksheets for testing, rather than having to manually type it all out.

Art DeptMechanical DeptPhysics Dept
Po'sNamePo'sNamePo'sName
0a1f1p
0b1g1q
0c0h1r
1d1i0s
1e0j0t
1k0u
1l1v
1m0w
0n
1o
 
Upvote 0
Hello Jeffrey

Looking at some of the advice given, I am trying to implement your proposal but the example you have given does not capture all of the data required from the example data?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,077
Messages
6,122,992
Members
449,094
Latest member
masterms

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