How to use SUMIF & VLOOKUP on filtered results

megamanx85x

New Member
Joined
Dec 24, 2019
Messages
5
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi there, I started a new job in which I have been tasked to filter out an excel sheet that logs all the jobs that were inspected everyday. It has multiple columns in which the critical data is filtering out the defect code and the quantity associated with it.

Originally I managed to make a formula in this mannner: =SUMIF('NAME OF SHEET'!K:K, VLOOKUP(A28,'NAME OF SHEET'!K:L,1,FALSE),'NAME OF SHEET'!L:L)

This worked fine as the entire two columns K and L would total up all the defect codes in relations to "A#" and etc. However this was a setback on my part as I need the sheet that sums up all the defect codes to be categorized by item #, there are more then thirty item #'s I can filter in the column and when I attempt to use the same formula it still grabs all the data in the two columns.

So now I tried to make a new formula that would only focus on the filtered data after the item # has been selected, and it hasn't worked obviously since I'm here; it looks like this:

=VLOOKUP(U2,IF(SUBTOTAL(3,OFFSET(K2:K100,ROW(K2:K100)-ROW(K2),0,1))>0,K2:L100)2,0)

I'm sure many of you will see what didn't go wrong but I am aware of the SUBTOTAL command 3 is not for SUM, this is the only option that works the way I have it set up and its only COUNTA which isn't what I need. If I attempt to use either 9 or 109 the formula errors out.

Its critical that I have this formula be on the second sheet and reference the original sheet location for columns/row K & L, please if anyone can help in correcting me on how to make sure it grabs only filtered data and SUMS it all up I would greatly appreciate it.

Also Merry Christmas!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi, we are pleased to help you, but please, put your data example, using XL2BB.
Note: If would necessary, pay attention to this post XL2BB 2 Square

I can't really use that feature on my work computer because i dont have permission to install additional software, nor can I make a copy of the excel sheet because of the high security we have in transferring files or emailing them. Sorry I wasn't aware of this.
 
Upvote 0
Ok, but paste HTML with some values, you can simulate an escenario (Excel table):cool:
 
Upvote 0
@megamanx85x, make a mock up of your data, make sure that your layout is exactly the same as in the original document.
Now just select and copy your range and (make sure the cog symbol at the top of the reply window is black and white, if it is orange click it to toggle it back) paste it in the thread .

It should post something like the below unless you are using Edge or Safari, which although not ideal it is usable.

Order IDProduct Name
106-5-N21Teatime Chocolate Biscuits
109-19-F61Filo Mix
103-23-F90Spegesild
106-18-F04Lakkalikööri
104-17-F18Zaanse koeken
109-17-F54Pavlova
106-11-N65Manjimup Dried Apples
106-25-N82Rhönbräu Klosterbier
105-30-F22Northwoods Cranberry Sauce
106-19-F37Gnocchi di nonna Alice
103-26-F95Spegesild
108-14-N32Gula Malacca
109-26-N78Northwoods Cranberry Sauce
103-16-N06Tourtière
107-22-N89Scottish Longbreads
105-9-N32Nord-Ost Matjeshering
109-5-F28Lakkalikööri
107-4-N28Nord-Ost Matjeshering
106-28-N12Inlagd Sill
104-12-F72Manjimup Dried Apples
 
Upvote 0
1577340897719.png


Here is a basic example of my data sheet, I omitted the other columns cause I dont have the information on them right now but these are the main three i am using. I filter the data with Item# so I can focus on the defect code and the scrap total for that defect code.

Defect Code and Scrap are columns K & L per my formulas.

Every time I change the item# in the drop down filter the defect codes will change and I need the formula to display the results shown only from the filter and not everything in the entire columns.
 
Upvote 0
Thats is the result are you looking for? ?

Book1
ABCDEFGHIJKLMNOPQR
1itemcolBcolCcolDcolEcolFcolGcolHcolIcolJdefect_codescrap
24500127-scratches15
34500103-tears45
44500127-scratches9
54500127-scratches19itemdefect_codeSum of scrap
64500127-scratches334500103-tears45
74500127-scratches1027-scratches76
845001 Total121
9Grand Total121
10
11
12
Sheet2
 
Upvote 0
That’s pretty much what I needed it to do, was to sum up all defect codes in a filtered result only. Fans total isn’t necessary, I have a second sheet where the formula is applied to each defect code hence the vlookup formula is set to search each defect code in the main sheet and add them all.
 
Upvote 0
Data in blue highlight is a Pivot table, and you can move this table, where you want.

See full example here
 
Upvote 0
Is this using the original formulas I had before or just a whole new pivot table? Can I possible expand the pivot table to hold all 100 defect codes!
 
Upvote 0

Forum statistics

Threads
1,215,357
Messages
6,124,483
Members
449,165
Latest member
ChipDude83

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