Find number of Unique Values per Item in Column B - vba

I have a Column B with part numbers. These may repeat and can occur in the same warehouse, (Column A) and also different warehouses. I want to find the amount of times any particular part number appears in a unique warehouse.
I have tried a PivotTable and do not know if I need a macro or just a formula.
How might I achieve this?

Sorry, I think Remove Duplicates and Filter Advanced may not be your best bet. But as I understand your requirement a PT should suit:

Related

Search entire workbook with two criteria

Gooday, Pls I'm partially new to vba. I have several spreadsheet in a workbook for a work station that is prone to making shortage or surplus in daily delivery as a result of human errors. I want a scenario where I can search the entire workbook to extract data from Column K(which displays shortage or surplus) , but it must meet a certain criteria in Column A(date of delivery) and Column D(location of delivery). In other words, I would like to search Column K to know if there is shortage or surplus for any day I choose to search based on date. Any form of assistance is highly appreciated. Thanks.
Your solution could include an InputBox and the Range.Find Method, where you search column A for date, read in the row, and look at column K of the same row. In fact, the Range.Find example is pretty easily modified for your needs.
But you mention location in Column D, so what constraints are on column D? You'll also need to be more specific about where/how you want to extract the data from column K.

Using Excel to to Return unique values for Identical lookup values

I am attempting to use VLookup to match a "Purchase Number" to a specific "Invoice Number". To accomplish this, I have several identifiers about the purchase that I put together to come up with a special "Concat ID". I then have a list of Invoice Numbers that also has the same list of identifiers to create the same "Concat ID'.
The problem I am running into is that the set of identifiers is not unique (aka a purchase of 10 Computers might happen multiple times a year, therefore it is in my list multiple times). Because of this, when I use Vlookup to match the 2 IDs, it always is giving me the same Purchase Number for each time the Concat ID is found (which is just the first occurrence of that Concat ID).
Since there is no other data that would allow for matching (because Invoice date and purchase date are not always the same date or even close to one another), I am just wanting to ensure that each Invoice Number has a unique purchase number.
I'm not sure if its possible, but I was hoping I would be able to perform the vlookup then just skip to the next time the Concat ID is found, allowing for no duplicates, but that hasn't been feasible for me. Because this is a file of 16000 rows, any insight is very appreciated.
I'm sure that's not the clearest explanation, so I've attached a screenshot of the 2 examples in case anyone has any insight. I've been using a simple VLookup, but I'm open to trying VBA or any other suggestions everyone has. As always, thank you Stack community in advance for any help/insight!
Purchase Info
Attempted Matchup with Invoice Info
I'm still not sure what you expect to do with the ConcatID purchase number, but to return the purchase numbers that match your specific ConcatID, generated in the manner you describe in your question, and "skipping to the next" in the case of identical ConcatID's, you can do something like the following;
Note that I made a Table out of your original data, and am using structured references. This allows a much smaller amount of data to be processed compared with referencing the entire column, and will also autoadjust the range as you add/remove rows
Also note that if your Table starts in other than Row 1, you will need to make an adjustment in the formula to account for that.
G2: =INDEX(PurchaseTbl[#All],AGGREGATE(15,6,1/1/(PurchaseTbl[Concat ID]=F2)*ROW(PurchaseTbl),COUNTIF($F$1:F2,F2)),7)
and fill down as far as needed
I've got a really dorky solution, but maybe it will help.
Use this formula to create a unique ID for each row. It will count how many times the specific Concat ID has been used previously in the table, then append it to the end. You can use the Concat ID Unique in your VLookup to get the correct Purchase Number.
=D2 & "_" & (COUNTIF(D$1:D1, "=" & D2))

Excel formula not working as expected

I have a sheet that shows max values spent anywhere. So I need to find most expensive place and return it's name. Like this:
Whole sheet.
Function.
Function in text:
=IFS((A6=MAX(D2:D31)),(INDEX(C2:C31,MATCH(A6,D2:D31,0))),(A6=MAX(H2:H31)),(INDEX(G2:G31,MATCH(A6,H2:H31,0))),(A6=MAX(K2:K31)),(INDEX(K2:K31,MATCH(A6,L2:L31,0))))
Basically I need to find a word left to value, matching A6 cell.
Thanks in advance.
Ok.. Overcomplicated!
Firstly, why the three rows? it's a lot easier if you just have one long row with all the data (tell me if you actually need 3 I'll change my solution)
=LOOKUP(MAX(D2:D31);D2:D31;C2:C31)
The MAX formula will lookup the biggest value in the list, the Lookup formula will then match it to the name.
Please note: If more than one object has the maximum price, it will only return the first one. The only way I can think of to bypass that would be to build a macro.
EDIT:
Alright.. Multi Column solution is ugly and requires extra columns that you can just hide.
As you can see you'll need 2 new columns that will find the highest for each row, 2 new columns that will find the value for each of these "highest" (in this case tree and blueberries) and then your visible answer will simply be an if statement finding out which one is bigger and giving the final verdict. This can be expanded with an infinite number of columns but increases complexity.
Here are the formulas:
MAX(H2:H31)
LOOKUP(A5;H2:H31;G2:G31)
MAX(L2:L31)
LOOKUP(C5;L2:L6;K2:K6)
IF(A5>C5;B5;D5)

Checking for same value in rows and calculate corresponding total

I have a large s/sheet. Values in column A correspond to values in column B, C & D.
I need to combine some rows which have same value in column A and automatically calculates total of value in column B in all corresponding rows.
Then i need to delete all unnecessary rows
Any ideas how i can do this with some code?
I think that you can use Power Query or VBA. Probably you will be able to achieve this with formulas, but it will be not flexible. With Power QUery you can combine data from multiple sources, clean and transform and even load directly into PowerPivot model. If you will have some detailed information please let me know. If you can upload the sample workbook with your data i will be able to provide you some more information.

Pivot Table Grand Total at the top

We have an Excel spreadsheet with the Grand Totals at the top using a Forumla, but this isn't on the actual Pivot Table it's just in the spreadsheet.
We have a client that wants the Grand Totals at the top of the Pivot Table and doesn't want us to use Formula. Does anyone know if this is possible (even using VBA or something, just so long as we don't look for a specific column or row name and compare with it (so no GETPIVOTDATA("Grand Total...)))?
This slightly hacky solution might help:
http://www.contextures.com/xlPivot13.html
Actually, it is possible. I'm doing just that. Here's how. Let's say I in my data source, I have 1 column that contains various work orders. In another column I have all my total dollars spent for each work order, and in my final column I have a number that identifies all of the various work orders as being part of one whole group, or falling under one heading. In my case, each of the work orders fall under one project number. This will place your total at the top and at the bottom. It will also allow you to turn on and off the bottom or the top by selecting a choice under Grand Total on / off for rows / columns.
Kevin L
I'd be happy to be proved wrong, but I don't think it's possible. I think you may have to do a little work on managing your client's expectations...
It generally works. but many people in my team make different pivot table layouts. So than this "fake" grand total column really does not work anymore.
To anyone having a similar challenge, you can accomplish this by adding rows at top of the pivot table and using GETPIVOTDATA to put the values in any cell you chose. Click here for details on how to use GETPIVOTDATA to get the Grand Total of a column in a Pivot Table. The best part is that is dynamic. There's no need to reference the Grand Total row specifically.