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.
Related
I have data in an excel spreadsheet in the form of
John | Age | 24
John | Location | Australia
John | Salary | $5000
Sue | Age | 28
Sue | Location | England
Sue | Salary | $6000
Is there an easy function to sort into a table along the lines of:
Name | Age | Location | Salary
John | 24 | Australia | $5000
Sue | 28 | England | $6000
Thanks in advance!
Use PowerQuery ...! Go to Data -> Get Data -> From File -> From Workbook and then follow these steps.
Rename first column to Name ...
Select Column2 and Pivot the data ...
Use these options in the pivot ...
Voila!
Select Close and Load to populate a new sheet ...
Result ...
Formula in F2 cell I used-
=INDEX($C$1:$C$6,MAX(($A$1:$A$6=$E2)*($B$1:$B$6=F$1)*(ROW($C$1:$C$6))))
If you have Excel-365 then you can use UNIQUE() function to E2 cell.
=UNIQUE(A1:A6)
=ROWS($A$6:A6)*3
=INDEX($A$6:$C$11;E6;1)
=INDEX($A$6:$C$11;(E6)-2;3)
=INDEX($A$6:$C$11;(E6)-1;3)
=INDEX($A$6:$C$11;E6;3)
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.
My table is something like below, currently I have a column as category with few types of cat names but now we what to have the categories as column header and the name's attached to it.
Table now;
ID | category | Name |
856| Car | Ford |
432| Motorcycle | Honda|
Desired;
ID| Car | Motorcycle |
856| Ford | (blank) |
432 | (blank) |Honda |
How can I do this?
Say your "Table now" table is named TableNow, and your "Desired" table is named TableDesired. Put this formula into your Car column, and fill over.
=IF(VLOOKUP([#ID],TableNow,2,FALSE)=TableDesired[#Headers],VLOOKUP([#ID],TableNow,3,FALSE),"")
I have one column with countries acronymns
SHEET 1
+------------------+
| Country_Acronym |
+------------------+
| EG |
| AE |
| PK |
| IN |
| LK |
+------------------+
I have another sheet with corresponding titles
SHEET 2
+------------------+----------------------+
| Country_Acronym | Country_Name |
+------------------+----------------------+
| EG | Egypt |
| AE | United Arab Emirates |
| PK | Pakistan |
| IN | India |
| LK | Sri Lanka |
+------------------+----------------------+
I need a formula to read the value on the first column of the first sheet and replace the value with the country_name on the 2nd sheet.
So, when you find EG replace with Egypt, when you find PK replace with Pakistan etc
You cannot change the value of cell itself depending on the value within that very self cell - without using VBA.
Instead you may use the below formula on the B2 of Sheet1 & copy down, then copy that column, paste onto Col:A as Values Only.
=VLOOKUP(A2,Sheet2!A:B,2,0)
I was hoping to get some assistance in writing a formula in excel.
I have a table that contains a list of employees and their cell phone number. However, the table is structured in such a way that there is a number of blank and duplicate rows.
Essentially, I am hoping to create a new table without any duplicates and blanks by performing a lookup on the respective cell phone numbers.
The problem is, when I do a standard Index/Match formula, the formula will grab just the first lookup value, which more often than not, is a blank row.
How would I modify this formula to say something like, "Look this value up. If the value is blank, lookup the second value"?
Here is a sample of what the table looks like:
Table 1 (Original)
+---------------+--------------+
| Employee Name | Cell Phone |
+---------------+--------------+
| Doe, John | |
| Doe, John | 111-111-1111 |
| Smith, Eric | 222-222-2222 |
| Jones, Dave | |
| Jones, Dave | 333-333-3333 |
+---------------+--------------+
Table 2 (What I want the table to look like)
+---------------+--------------+
| Employee Name | Cell Phone |
+---------------+--------------+
| Doe, John | 111-111-1111 |
| Smith, Eric | 222-222-2222 |
| Jones, Dave | 333-333-3333 |
+---------------+--------------+
=Index(Table1[Cell Phone], Match([Employee Name], Table1[Employee Name],0))
How about the first non-blank match?
=INDEX(B:B, AGGREGATE(15, 6, ROW($2:$999)/((A$2:A$999=F2)*(B$2:B$999<>"")), 1))
'listobject table alternative
=INDEX(Table1[Cell Phone], AGGREGATE(15, 6, (ROW(Table1[Cell Phone])-ROW(Table1[#Headers]))/((Table1[Employee Name]=F7)*(Table1[Cell Phone]<>"")), 1))