Automatic Filter Drill Down

Dmak

New Member
Joined
Aug 6, 2021
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hi there,

Hope everyone is doing well.

I am trying to create a macro which takes the value of a cell (based on the condition of it being "SEMI", "RAW", "PKG"). I then take the BOM No. which is in the first cell of the same column with the cell condition and use this cell value to filter column "E". (NO.) I do this for every condition met until there is no more condition to check for.

There are a lot more rows then this (35K Plus so I could not use the XLBB Tool).

Here is what the sheet looks like:


1628270422890.png



Basically, I am currently at the stage of using a FOR EACH loop that checks each if cell in column1 = "SEMI" or "PKG" or "RAW".... then it would select the Production BOM .NO (which in this case is CK00049) and use this cell value to filter column "E" (NO.) which would drill down the data, This loop will repeat again onto the next stage until a single "FG" is returned which then the value of the 'FG' could be returned into "RESULTS". Then I wish to reset the filter and move onto the next SEMI found.

On the second step of the drill down it would something like this:

1628271639747.png


As you can see: the bottom two rows (C:38165, C:38286) are tagged as semi, so I would have to again use these cell value and filter column "E" to drill down further until the final is returned. Using C:38165 this would be returned:

1628271890576.png


After this, I would copy and paste the first cell as a result, and then would drill back out to repeat with C:38286 (if not more). IF not the case, I would reset the whole thing, with the initial filter, and move onto to the next condition of it being "SEMI" or "RAW" or "PKG" and etc.


I understand that this will be a nested for each loop with multiple stages and with some complicated conditions, but I cant seem to figure if its even possible to print out all the conditional results in one go.


Here is the structure of what I have so far:

First search to see if product type condition is met.

if true: then take first cell in active column and use cell value as filter for column "E" (NO.)
then run search condition again
if it was false here, open new sheet with results
if true take cell again and filter down




if false: return "No queries found" end if and go to end code

then
run search condition again

if true take cell again and filter down

if anyone can point me in the right direction or create a piece of code that can loop at least once, it will be greatly appreciated.

I am pretty stuck with this so please help out!
 
Last edited by a moderator:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
If anyone would like me to elaborate please let me know. I would really appreciate any help offered!
 
Upvote 0
Hi, @Dmak. Welcome to the Forum.
Could you create an example? Create a mock up data, say 20 rows, and also show us what the result should look like.
Please use xl2bb to post your example.
 
Upvote 0
Hi, @Dmak. Welcome to the Forum.
Could you create an example? Create a mock up data, say 20 rows, and also show us what the result should look like.
Please use xl2bb to post your example.



Hi Akuini,

Thanks so much for the response. I have created an example scenario with mock up data below:


BOM explosion Project.xlsm
ABCDEFGHIJ
1Production BOM No.Version CodeLine No.TypeNo.DescriptionScrap %Quantity perYield Pct.Column1
81400140-1FN20205ItemDI00069GB Nfc GMOF STMP CLK466.6879251700680394.3396226415094FG
501600103-1FN202010ItemDI00069GB Nfc GMOF STMP CLK468.35294.3396226415094FG
511600130-1FN20215ItemDI00069GB Nfc GMOF STMP CLK468.5714394.34FG
531600407-1FN202010000ItemDI00069GB Nfc GMOF STMP CLK467.594.3396226415094FG
194CK0004910ItemDI00069GB Nfc GMOF STMP CLK460.52594.3396226415094SEMI
195CK0007210ItemDI00069GB Nfc GMOF STMP CLK460.8773894.3396226415094SEMI
196CK000955000ItemDI00069GB Nfc GMOF STMP CLK460.5559594.3396226415094SEMI
197CK0009810000ItemDI00069GB Nfc GMOF STMP CLK460.52194.3396226415094SEMI
198CK0010020000ItemDI00069GB Nfc GMOF STMP CLK460.5845294.3396226415094SEMI
199CK0010810ItemDI00069GB Nfc GMOF STMP CLK460.438194.3396226415094SEMI
200CK0010910ItemDI00069GB Nfc GMOF STMP CLK460.6011994.3396226415094SEMI
202CK0011110ItemDI00069GB Nfc GMOF STMP CLK460.7047694.3396226415094SEMI
203CK001135ItemDI00069GB Nfc GMOF STMP CLK460.72594.3396226415094SEMI
204CK0015010ItemDI00069GB Nfc GMOF STMP CLK460.55394.3396226415094SEMI
209CK0085610000ItemDI00069GB Nfc GMOF STMP CLK460.136994.34SEMI
210CK0085710000ItemDI00069GB Nfc GMOF STMP CLK460.3394.34SEMI
211CK0085810000ItemDI00069GB Nfc GMOF STMP CLK461.6594.34SEMI
212CK0089410000ItemDI00069GB Nfc GMOF STMP CLK461.059594.34SEMI
213CK0089710000ItemDI00069GB Nfc GMOF STMP CLK460.2833394.34SEMI
214CK0092710000ItemDI00069GB Nfc GMOF STMP CLK460.398894.34SEMI
216CKF0084210000ItemDI00069GB Nfc GMOF STMP CLK460.0142894.34SEMI
Sheet4






Firstly, to get started, I would have a very big data set (>30K Lines). I would filter it down to one single NO. (Which is column E, DI00069 In this case). What you see above are the filtered results. This part isn't very important, what comes next is.

On the far right I did a XLOOKUP from a item list sheet, which tells me the category of the product, ANYTHING that is FG (Finished Good) doesn't need to modified in any way but what ever is "SEMI" "RAW" OR "PKG" must be drilled down. I do this by taking the corresponding BOM NO. (First Column) and take that value, and set it as a filter in column "E"

So, going down the list, we notice "SEMI" on the 5th row (R:194). So, I would look to the far left for the corresponding BOM No. which is CK00049. Essentially, this number is is not a finished product, so to find where this item feeds into, which is a finished good, we would need to search for its components. Again, I take this number and input it into the filter in column in "E" and the data would now look something like this:



BOM explosion Project.xlsm
ABCDEFGHIJ
1Production BOM No.Version CodeLine No.TypeNo.DescriptionScrap %Quantity perYield Pct.Column1
101400360-110ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
111400360-100010ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
271500847-1FN202010ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
281500847-1FN202110ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
291500847-2FN202010000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.238FG
471594918-110ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
841601195-1FN202010000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
851601195-1FN202110000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
861601195-1CA10000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
871601195-210000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
881601195-3FN202010000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
891601195-3FN202110000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
901601195-3CAFN202110000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.238FG
911601195-4FN202010000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
921601195-4FN202110000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
931601195-5FN202010000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.238FG
941601195-5FN202110000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.238FG
951601195-6FN202010000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.238FG
961601195-6FN202110000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.238FG
971601195-710000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.238FG
1381800922-D10000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB58595.2380952380952FG
1391801311-110000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5695.2380952380952FG
239WP119510000ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5195.2380952380952SEMI
240WP84710ItemCK00049Cookies - 8pc GB Family 360gr TFF MB5195.2380952380952SEMI
Sheet4

(I dont know if this is the true definition of a drill down, but this is what i think a drill down is lol. I hope there is a better way of doing this.)


So, as you can see, the data looks different, but its essentially the same thing again. I would then again go down searching for categories mentioned above. In this case, the 2nd last row we find the BOM: WP1195. Inputting this into the filter of column "E" would return:


1628354791138.png

(Almost running our of characters so could not use xlbb, my bad!)

This is the final product that it feeds into. So, it would be classified as a RESULT, pasted into a different sheet. I would then go back to the 2nd part and also drill down on the last row : WP847 and copy and paste the result to the next sheet!


That was was 1 iteration of the drill down, as you remember there are more SEMI'S in the first level so I would then have to go back to level 1: with the initial filter of DI00069 and then continue going down the list to the next match. Sometimes its only 1 drill down, other times it is a lot!


Currently, I am using a FOR EACH loop to search down the list but cannot progress any further because I do not understand how I can reloop to get the results. There has to be a much smarter way of doing so, and I hope you can lead me down the right path!



Hopefully this gives you a better understanding, Please let me know if you need anything else Akuini!


Best,

Dmak
 
Upvote 0
I would then have to go back to level 1: with the initial filter of DI00069 and then continue going down the list to the next match
by next match you meant the next SEMI which has BOM no CK00072?
and repeat the process as the first SEMI before?
and after that do it until the last SEMI?

I think I understand the main requirement. But actually, I was hoping you can provide a sample that hasn't filtered yet, so I can test it easier. And also I probably will use an array not filter to do it.
So could you upload your workbook with not filtered data (and please remove sensitive data) to a sharing site like dropbox.com or google drive? And then share the link here.
 
Upvote 0
another question:
This is the final product that it feeds into. So, it would be classified as a RESULT, pasted into a different sheet.
So the criteria for the final product is: if the filtered data shows only 1 row and it has FG in col J?
 
Upvote 0
There are a lot more rows then this (35K Plus so I could not use the XLBB Tool).
Following up on post #5 request:
If your 35K data isn't sensitive material then it's better if you can share it (via dropbox.com or google drive). I'll need it for speed test.
 
Upvote 0
by next match you meant the next SEMI which has BOM no CK00072?
and repeat the process as the first SEMI before?
and after that do it until the last SEMI?

I think I understand the main requirement. But actually, I was hoping you can provide a sample that hasn't filtered yet, so I can test it easier. And also I probably will use an array not filter to do it.
So could you upload your workbook with not filtered data (and please remove sensitive data) to a sharing site like dropbox.com or google drive? And then share the link here.
Yes, it could be SEMI, PKG, RAW, but essentially those are the 3 matches that need to be drilled down.
 
Upvote 0
another question:

So the criteria for the final product is: if the filtered data shows only 1 row and it has FG in col J?
Yes, in some cases there may be more but as long as there are no SEMI, PKG , Raw in the criteria
 
Upvote 0
Following up on post #5 request:
If your 35K data isn't sensitive material then it's better if you can share it (via dropbox.com or google drive). I'll need it for speed test.

Here is the link to the file. I have removed all the unnecessary columns and fields. Please let me know if anything else is needed!
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,891
Members
449,194
Latest member
JayEggleton

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