Excel getting totals for categories across worksheets - excel

So I have column A (cat) and column B (Amt) on lots of separate works sheets.
Cat | Amt
1 | 3.4
4 | 7.4
2 | 8.4
4 | 9.4
What I need is to have a grand total for each category type across all the worksheets.
So a total for category 4, a total for category 2 etc.

This is more suitable for VBA solution, however if you know how many unique "Cat" you have, then it can be done without VBA.
For each sheet on C column add SUMIF formula, this will give sum for each group.
C2=SUMIF($A:$A,A2,$B:$B) - copy it down for each row.
On Sheet11 Column A is your unique "Cat" list. Columns B1 to K1, name them as Sheet1, Sheet2, ...Sheet10.
B2=IFERROR(VLOOKUP($A2,INDIRECT(B$1&"!$A:$C"),3,FALSE),0) - copy it for each row, column.
Column L will be GrandTotal.
G2=SUM(B2:K2) - copy it for each row.

Related

Excel Formula - Return unique count of range based on multiple criteria from different tables

I have three tables: Parties, Document Detail and Document. (Note, they are not table formatted, so all references are based on cell and sheet location, not table aliases)
I want to return a unique count of the parties in each Document using an Excel Formula. My problem is, I would usually use a =COUNTIFS() formula for this, which would be something like the following, which I would put in B2 of Sheet 3 (Document table):
=COUNTIFS(Sheet2!A:A,A2,Sheet2!B:B,Sheet1!A2)
But this will only return the count of one criteria at a time, not a count checking for all values of the parties table per document. I understand it should be able to be done with an array formula, but I can't figure it out. Bonus points if someone can figure out how to do it with a non-array formula!
Sheet1 - Parties Table
A
1|Parties |
+-----------------+
2|Education Officer|
3|Elder |
4|Family Support |
5|Interpreter |
Sheet2 - Document Detail Table
A B
1 |Doc ID | Party |
+-------+-----------------+
2 |FID0001|Education Officer|
3 |FID0001|Elder |
4 |FID0001|Education Officer|
5 |FID0001| |
6 |FID0001| |
7 |FID0002|Elder |
8 |FID0002|Interpreter |
9 |FID0002|Family Support |
10|FID0002| |
Sheet3 - (Desired Result) - Document Table
A B
1|Doc ID |Party Count|
+-------+-----------+
2|FID0001| 2 |
3|FID0002| 3 |
TL:DR
What combination of Excel formulas can I use to return the number of unique parties referenced in each document?
Based on this answer by Barry Houdini and expanded to include the DocID criteria
Put a helper column on Sheet2, lets say in colum C
=IFERROR(1/COUNTIFS($B:$B,$B:$B,$A:$A,$A:$A),0)
and copy down for all data rows
Then, in Sheet3 Party Count Formula is
=SUMIFS(Sheet2!$C:$C,Sheet2!$A:$A,$A:$A)
The non-Implicit Intersection versions
Sheet2 cell C1
=IFERROR(1/COUNTIFS($B:$B,$B1,$A:$A,$A1),0)
Sheet3 cell B2
=SUMIFS(Sheet2!$C:$C,Sheet2!$A:$A,$A2)

Excel IF Formula 3

I have a sheet with rows of data that I want to copy to a different sheet if the name in column a equals a certain value. For example:
A | B | C
Name | Color | Amount
Sue | Blue | $400
Joe | Green | $1000
Sheet Sue needs to bring columns B and C from Sue's records to it's worksheet if column a equals Sue
Sheet Joe needs to bring columns B and C from Joe's records to it's worksheet if column a equals Joe
and so on and so forth...
Can anyone help!?
Well, if you don't have too much data you can do this with array formulas.
Set up your main sheet (assuming it's Sheet1) with named ranges. Your A2:A100 name it Name, B2:B100, name it Color, and C2:C100 name it Amount. (Adjust the range as necessary)
Then, in each of the people's sheets, have header rows called Name, Color, and Amount. Then you can use this formula (entered with CTRL+SHIFT+ENTER):
=INDEX(INDIRECT(A$1),SMALL(IF(INDIRECT($A$1)=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255),ROW(INDIRECT($A$1))-ROW(Sheet1!A$2)+1),ROWS(Sheet1!$A$2:A2)))
Wrap IFERROR([formula],"") to hide the #NUM errors when you reach the end of the data.

compare 2 excel columns with data in adjacent columns

I have seen a few answers which were close to what I am looking for, but can't quite figure it out. I apologize as I am not a programmer, but am tasked with these types of things periodically.
I have a spreadsheet with data in multiple rows. I would like to compare column A with C and have them align, and then the data in B move with column A. (I can rearrange the columns if need be to make this work.
I have this:
Inventory ID# count Original ID# vendor item number
1234 2 1000 vendor 1 1234566
1456 1 1234 vendor 2 546564
7000 3 1456 vendor 3 af4566
2003 vendor 4 56778
7000 vendor 1 788asd
What I want it to look like is after:
Inventory ID# count Original ID# vendor item number
1000 vendor 1 1234566
1234 2 1234 vendor 2 546564
1456 1 1456 vendor 3 af4566
2003 vendor 4 56778
7000 3 7000 vendor 1 788asd
I have tried macros, and VLOOKUP, but can't figure out how to have the count move with the inventory ID # Thank you for your help.
I'll assume your data starts in Sheet1!A1
Move the Invenotry ID# and count columns to a different sheet (say, Sheet2). Then replace the value in cells A2 with the following:
=IFERROR(VLOOKUP($C2,Sheet2!$A:$B,1,FALSE),"")
and similar for cell B2:
=IFERROR(VLOOKUP($C2,Sheet2!$A:$B,2,FALSE),"")
Fill it down. The VLOOKUP will place your id's and counts in the right rows, and the IFERROR( ... ,"") part will put a blank string where there is no match, so it will look like you desired table
If your data starts from cell A1, insert 2 columns C and D like below,
Enter the below formula in cell C2 and drag it right to column D and then down throughout the range,
=IFERROR(INDEX($A:A,MATCH($E2,$A:$A,0),COLUMN(A1)),"")
You can then copy-pastespecial Column C and D to A and B and delete C and D.

Count Max Values of Top 1,2,3 on another workbook

I've trying to come up with a formula to automatically populate top 1,2,3 text occurrences from another Workbook, however I have multiple criterias that seem to be making it more difficult for me.
So in Workbook 1, I have:
Column A
Dates ranging from 2106-Present
Column B
Random PartNumbers with a mix or numbers and letters
(Note partnumbers are not a definite list as they change and new one implemented)
Column C
Location
This list has over 10k records
I'm creating a separate workbook (template)
Column/Row A1 Top part Number 1
Column/Row A2 Top part Number 2
Column/Row A3 Top part Number 3
Formula has to have a condition for month range and location
Column B1 would display the part number (1st place)
Column C2 would display the count
And so on...
For example:
Template would display:
Top Part Number | Part Number | Count
1 | P23 | 23
2 | 345 | 19
3 | D43 | 16
(Count is determined by month and location of choice)
Any help would be appreciated

Excel: Create Custom Sheet 2 Based on Data in Sheet 1

I have two sheets in a spreadsheet. Each sheet has a first column with common values (however they are not sorted the same and they are not all there in each sheet).
What I'm trying to do, if possible, is put a formula in sheet 2, where, if column 1 is a match for sheet 1, copies selective data from certain columns in that same row in sheet 1, to certain columns in sheet 2.
Example:
Sheet 1 has a heading setup and sample data row like this:
Title | Day of Week | First | Last
Supervisor | Wednesday | Mike | Jones
Sheet 2 has a heading setup and sample data row like this:
Title | Surname | Weekday
Supervisor | (empty cell) | (empty cell)
After running the mystery formula I'm looking for, placed in the 2 empty cells above, sheet 2 should match on the Supervisor key in sheet 1 and copy in data I have specified into each column, such as:
Title | Surname | Weekday
Supervisor | Jones | Wednesday
(In this case I have told it to map the "day of week" column to weekday, and map the "last" column to "surname").
I hope this is easy/possible??? Help???
VBA is not necessary. You can use a simple VLOOKUP:
=VLOOKUP(cell to look-up,
range where you want to look up the values (first column *must* contain the keys to look-up) including all columns that you want to retrieve,
the position of the column to be retrieved relative to the first column specified in argument 2,
0 (specifies you want an exact match))
For example:
=VLOOKUP(A1, Sheet1!$A$1:$D$150, 2, 0) ' Retrieves the 2nd column matching criteria in A1
Please notice, however, that you need your keys to be unique. Matching information based on the title seems a bit odd since it is likely there will be more than one person assigned to a certain role. For example, there may be more than 1 supervisor.
Use INDEX and MATCH (better than VLOOKUP).
I suggest renaming your headers so they match on both sheet.
Sheet 1 should be :
Title | Weekday | First Name | Surname
In sheet 2, cell B2 type in
=INDEX(Sheet1!$A:$D,match($A2,Sheet1!$A:$A,0),match(B$2,Sheet1!$1:$1,0))
You can drag and drop it in column C as well, it will work since you are using two MATCH functions with the cells properly anchored.

Resources