I have an excel workbook where I am trying to count the number of apples in a named table. The workbook has multle sheets each named Jan, Feb, Mar, etc. with a corresponding table range of the same name.
My main worksheet has a list of months as columns and fruit as rows, I want to use a countif or suitable function to count the number of each fruit per month using the column heading as the worksheet portion of the formula.
This is what I have tried, this works, but has to be manually coded for each month, i would prefer it be more dynamic.
=COUNTIF(JAN[Labels],$A2)
Note: A2 contains the word apple
I have tried to get the month from the column date but it doesnt work
=COUNTIF(TEXT(E25,"mmm")[Labels],$A2)
This is roughly what the "master" table should look like (for clarity)
| | Jan-20 | Feb-20 | Mar-20 | .... |
| Apple | 4 | 3 | 5 | ... |
| Pear | 5 | 4 | 9 | ... |
EDIT:
Just to assist with anyone trying to help, this is roughly what a table on another sheet will look like:
| invoice | labels|
| 12535 | Apple |
| 12536 | Pear |
| 12537 | Apple |
This table would be a named table of Jan or Feb, etc.
Please try this:-
=COUNTIF(INDIRECT(TEXT(G2,"mmm")),"A")
G2 contains a proper date.
Here is a variation of the above where column 2 of the table is specified as the range to count in.
=COUNTIF(INDEX(INDIRECT(TEXT(G2,"mmm")),0,2),"B")
If you must use column captions to identify the column I would suggest MATCH to find it.
OK, so I found an answer, combining the above answer by Variatus with an additional new row.
| A | B | C | D |
1| | Jan-20 | Feb-20 | Mar-20 |
2| |JAN[Labels]|FEB[Labels]|MAR[Labels]| <- =UPPER(TEXT(B1,"MMM"))&"[Labels]"
3|Apple | 5 | 7 | 3 | <- =COUNTIF(INDIRECT(B$2),$A3)
4|Pear | 7 | 2 | 9 |
5|Orange| 1 | 3 | 3 |
So formula in B2 makes an uppercase text value of the month from B1 plus the column name Labels.
The formula in B3 (and down) counts the number of instances of the fruit from the named table & column shown in B2.
Related
I have an excel formula that I need help with, since I'm not that savvy on excel.
The formula is the following:
=IFERROR(INDEX(Liste!$C$2:$N$10000,AGGREGATE(15,6,(ROW(Liste!$A$2:$A$10000)-ROW(Liste!$A$2)+1)/ISNUMBER(SEARCH("BOX"," " & Liste!$B$2:$B$10000 & " ")),ROWS($A$4:$A4)),COLUMN()-1),"")
This formula looks on another sheet (Liste) for lines containing the word BOX on column B and show them on "ROWS($D$4:$D4)" (in this case) starting from Column "C".
I'm not even sure if that formula orders the results on column "B" since they're all the same with the word "BOX".
It works prefectly, the only think I can't achieve (and I've tried diferent combinations) is to change that code to make it show the results in order according to column "C" (not column B).
Sample Data:
Sheet "Liste"
|-----------|----------|-----------|
| B | C | D |
|-----------|----------|-----------|
| NOTBOX | 5 | SAMPLE |
| BOX | 3 | SAMPLE |
| BOX | 1 | SAMPLE |
| BOX | 2 | SAMPLE |
| NOTBOX | 4 | SAMPLE |
|-----------|----------|-----------|
Current Result:
|-----------|----------|
| A | B |
|-----------|----------|
| 3 | SAMPLE |
| 1 | SAMPLE |
| 2 | SAMPLE |
|-----------|----------|
Desired Result:
|-----------|----------|
| A | B |
|-----------|----------|
| 1 | SAMPLE |
| 2 | SAMPLE |
| 3 | SAMPLE |
|-----------|----------|
Can someone give me a hand?
One thing I forgot to state is that I need to drag this formula around (rows and columns) so it's important that I can drag it on a large zone (if lines are added in the future) and that it ignores the errors (blank).
Thank you in advance
Here is an example on how you could do this:
Formula in F2:
=SMALL(IF($A$2:$A$6=$E$2,$B$2:$B$6,""),ROW(A1))
Or in French
=PETITE.VALEUR(SI($A$2:$A$6=$E$2;$B$2:$B$6;"");LIGNE(A1))
Formula in G2:
=INDEX($C$2:$C$6,MATCH(F2,$B$2:$B$6,0))
Or in French
=INDEX($C$2:$C$6;EQUIV(F2;$B$2:$B$6;0))
Note: The first formula is an array formula and need to be confirmed through CtrlShiftEnter.
Drag them both down and include an IFERROR if you drag these formula's down and you don't want to see errors once there are no more hits.
I have two sheet in excel.
In sheet2 I have a table with these fields:
NAME, SURNAME, CITY, AGE
In sheet1 I have to set field CITY and I want that table under this field will be with all the rows from sheet2 with selected CITY.
If I do a VLOOKUP I obioubsly get only first row of table.
Example:
A | B | C | D
NAME | SURNAME | CITY | AGE
Alex | Green | Rome | 18
Max | Brown | Rome | 21
Mary | White | Milan | 33
George | Violet | Rome | 27
In sheet 1 I have
A | B | C | D
CITY | Rome
NAME | SURNAME | CITY | AGE
VLOOKUP| VLOOKUP | VLOOKUP | VLOOKUP
VLOOKUP| VLOOKUP | VLOOKUP | VLOOKUP
VLOOKUP = VLOOKUP($B$2;Sheet2!A:D;1;0) -->
I wanted ALEX, MAX, GEORGE; I have ALEX, ALEX, ALEX
How can I do this without macros?
Thank you
For a simple data configuration like your sample pu this in Sheet1!A3 and fill both right and down,
=INDEX(Sheet2!A:A,AGGREGATE(15,6,ROW($2:$9)/(Sheet2!$C$2:$C$9=$B$1),ROW(1:1)))
For more complicated data configurations and retrievals put this in Sheet1!A3 and fill right and down,
=INDEX(Sheet2!$A:$D, AGGREGATE(15, 7, ROW($2:$9)/(Sheet2!$C$2:$C$9=$B$1), ROW(1:1)), MATCH(A$2, Sheet2!$1:$1, 0))
Use an IFERROR function 'wrapper' to avoid displaying worksheet errors when you run out of data to retrieve.
What I'm trying to do is a little complex but I think it's doable in Excel.
I have two worksheets in a workbook on sheet one I have this...
| Code1 | Code2 | Code3 | Code4 |
| BA1 | xxxxx | xxxxx | |
| BA2 | xxxxx | xxxxx | |
| BA3 | xxxxx | xxxxx | |
And on the second sheet...
| CodeA | CodeB | CodeC | CodeD |
| BA1 | 1 | date | text |
| BA3 | 1 | date | text |
| BA1 | 2 | date | text |
| BA2 | 1 | date | text |
| BA1 | 3 | date | text |
| BA3 | 2 | date | text |
| BA2 | 2 | date | text |
What I want to do is lookup Code1 on sheet one and find it in the second sheet in CodeA then find the highest CodeB for CodeA and then concatenate CodeC and CodeD and place them on Sheet one in Code4.
I hope that makes sense, Thanks for any advice.
I think I understand. Does this look correct?
Sorry for the swedish formulas but it's an array formula that you add with CTRL+SHIFT+ENTER.
The formula in english is:
{=MAX(IF(Data=A2,CodeB;-1))}
And the named range Data is Column H and I, and CodeB is Column I.
If it does not find the value it returns -1
Sorry noticed now that I only did half of the job.
Make another named range called Table that spans column I to K (Code B -> Code D).
And in column code3 add this formula:
=Vlookup(B2,Table,2,false)
And in code4:
=Vlookup(B2,Table,3,false)
And you should get:
This should find the results you are looking for.
This is an array formula so you will need to press CTRL+SHIFT+ENTER once you have entered it into the formula bar, this will have to done for every formula you add to the column.
As it is an array formula I have only written it to reference rows 1 to 18, you will need to update all references to include you last row.
Columns titled CODE1(to 4) are on the first sheet (Sheet 1)
Columns titled CODEA(to D) are on the Second sheet (Sheet 2)
=CONCATENATE(VLOOKUP(CONCATENATE(A2,MAX(IF(Sheet2!A:A=A2,Sheet2!B:B,-1))), CHOOSE({1,2},Sheet2!A1:A18 & Sheet2!B1:B18, Sheet2!C1:C18 ),2,0)," ",VLOOKUP(CONCATENATE(A2,MAX(IF(Sheet2!A:A=A2,Sheet2!B:B,-1))), CHOOSE({1,2},Sheet2!A1:A18 & Sheet2!B1:B18, Sheet2!D1:D18 ),2,0))
If you do not require a space between the dates, just remove " ", from the middle of the formula.
Friends, I'm hoping you can help. I'm fairly certain I found a solution to this problem below a while ago, but silly me didn't write it down and now I can't remember how I did it. I'm drawing a blank on what to search for (Google is flooded with answers on "dynamic named ranges", which is not what I'm aiming for here). So, the question:
How can I define a range within a formula (say, RANK for example) that moves as I progress down through a table? I'm trying to avoid using INDIRECT, because it becomes a bit of a memory/processor hog when repeated throughout a large table. Pretty sure there is another way, maybe with INDEX or MATCH?
A simplified version of the data would appear as follows:
Column A has a bunch of reference numbers, each one repeats a few times.
Column B has a bunch of timestamps
Column C is where I would like to rank the timestamp in column B, as compared to all other timestamps that share the same reference number in column A.
The result set should look like this:
| A | B | C |
| abc123 | 01/01/2014 12:30 | 1 |
| abc123 | 01/02/2014 12:30 | 2 |
| abc123 | 01/02/2014 13:30 | 3 |
| abc123 | 01/03/2014 09:30 | 4 |
| def456 | 01/01/2014 12:30 | 1 |
| def456 | 01/01/2014 12:45 | 2 |
| xyz987 | 01/02/2014 12:30 | 1 |
| xyz987 | 01/02/2014 16:30 | 2 |
| xyz987 | 01/03/2014 11:30 | 3 |
Any ideas on what would be the least taxing solution for the processor in this case?
So here is the trick:
copy and paste in C1 and drag and fill down till end.
=IF(A2=A1;SUMPRODUCT(--(A$1:A$9=A1);--(B1>B$1:B$9))+1;SUMPRODUCT(--(A$1:A$9=A1);--(B1>B$1:B$9))+1)
this is an array formula, so press ctrl+shift+enter to calculate the formula
Here is the example sheet in this file downloadable from this link
P.S. remember to adjust the formula to your regional settings by replacing the ";" with "," . Have fun.
What I am Trying to do is
lets say I have a excel sheet with
rows
ProductNo | Product | Sku | Price | Image | Thumb
25 | Shirt Blue | 4251 | $10 | shirt.jpg | shirtthumb.jpg
2 | Shirt Green | 4581 | $17 | green.jpg | greenthumb.jpg
8 | Shirt Black | 4561 | $15 | black.jpg | blackthumb.jpg
and just in different rows or on another excel sheet
ProductNo | Product | Sku | Price | Image | Thumb
25 | Shirt Blue | 4251 | $52 | |
2 | Shirt Green | 4581 | $42 | |
8 | Shirt Black | 4561 | $65 | |
How can i change the first table to update if the the second table or sheet columns data is different on specified columns and if the cells are empty forget about them ignore them and just replace the values from the second table onto the first
Final would be
ProductNo | Product | Sku | Price | Image | Thumb
25 | Shirt Blue | 4251 | $52 | shirt.jpg | shirtthumb.jpg
2 | Shirt Green | 4581 | $42 | green.jpg | greenthumb.jpg
8 | Shirt Black | 4561 | $65 | black.jpg | blackthumb.jpg
I have tried a couple of excel functions but they do not work since i have so many products to be doing cell additions
I tried doing in Vl but got confused and macro i dont even know what it is
Im open to whatever visual, functions just as long as i can perform the task
if anybody know hos let me know
Thank You
in stead of having the fixed values I propose you use a permanent formula in the specified columns.
Now to do this I would use a VLOOKUP() function. I am assuming that your ProductNo is the element that never changes therefore all the other columns will get a VLOOKUP() function.
Now if I understand correctly you MIGHT have an update in the 2nd table for the 1st table, but any empty cells in the 2nd table should be ignored.
I am also assuming you wish to see when an element will change because of the update therefore I propose the following:
In the first table add for the block of columns elements that might need an update: 2 blocks of columns, the first with the result of combining (the COMB-block) and the second with lookups from the 2nd table (the LOOKUP-block). For convenience of explaining I put the two tables in the same workbook on the sheets called table1 and table2
ProductNo | Product | Sku | Price | Image | Thumb | Product_comb | Sku_comb | Price_comb | Image_comb | Thumb_comb | Product_lookup | Sku_lookup | Price_lookup | Image_lookup | Thumb_lookup
Now start with formulas in the LOOKUP-block, use VLOOKUP(), such as this one for the *Product_vlookup* column:
=IFERROR(VLOOKUP($A2,table2!$A:B,COLUMNS(table2!$A:B),FALSE),"")
The IFERROR is for the case the product in table1 cannot be found in table2
For the formulas in the COMB-block the following will prefer the table 2 result over the table 1 result. As VLOOKUP of a matching ProductNo with an empty Element (for example for the Image) will result in a 0 (zero) returned all zeroes are regarded false lookup results as well. This is the script for the *Product_comb* column:
=IF(OR(ISBLANK(L2),L2=0),B2,L2)
As a final step to identify the products that changed you can either add a column that compared the original value with the _comb value:
=AND(B2=G2,C2=H2,D2=I2,E2=J2,F2=K2) (this returns true for no changed columns and false for any changed column)
Or use conditional formatting on each element separately or on the combination as the AND() formula shows.
As a final step in your process of updating you could copy all records from the COMB-block and paste it over the original elements.
If you have any further questions please ask.