I am trying to apply vllokup for a specific month of a specific year. My formula works for string lookup value but not works for date. here I attached my effort
First of all VLOOKUP() will not work in this case because VLOOKUP() always lookup values on first column of table then return value from corresponding row from specified column. So, you first column is strings and vlookup do not find dates on first column. Use Index/Match instead.
=INDEX(B3:B5,MATCH(D1,C3:C5,0))
You can also use FILTER() function.
=FILTER(B3:B5,C3:C5=D1)
Query() will also work-
=QUERY(B3:C,"select B where C= date '" & text(D1,"yyyy-mm-dd") & "'")
Vlookup works by searching columns to the left of the searched column. So you should modify your sheet to look like this (if possible) :
However, you should also take into account that the formatting of your cells could be misleading. If your D4cell has the value 1/Jan/2022 and your C6 cell has the value of 2/Jan/2022, then both of them will show as Jan 2022, but your formula will still return N/A because the real values of the cells are different.
Related
I wish to construct 2 current status columns so as find the last values in each row in Excel:
one for the last Date and the other for the last person who needs to act.
Please see the attached jpg To return the last values in a row for Date and Person to Act
I have tried to use the excel functions, namely, INDEX or LOOKUP but to no avail because of the 3 Remarks columns within the table.
I would appreciate it if you could advise me how to craft a VBA code to the above query.
From LC TAN 2020-02-13
You're on the right track.
you can use LOOKUP to return the last element in an array
BUT you have to ensure your array only has the elements that you want to consider
There is a variation of the INDEX function where you can enter an array for the column (or row) argument and return selected items. You enter the array, or arra constant, in a format like:
N(IF(1,*array or arrayConstant*))
So, a formula that would work for your requirements would be:
L6: =LOOKUP(2,1/LEN(INDEX($B6:$J6,N(IF(1,{2,5,8})))),INDEX($B6:$J6,N(IF(1,{2,5,8}))))
and fill down.
You can use MAX for the date to find the latest date in that row.
You can then use IFERROR and VLOOKUP to find the action with that date. i.e. lookup the date that MAX has returned in the first set of columns, and if that returns an error, look in the second. If the second returns an error, look in the third.
As per your sheet, the formula for L6 would be =MAX(B5:I5)
The formula for M6 would be =IFERROR(VLOOKUP(L5,B5:C5,2,FALSE),IFERROR(VLOOKUP(L5,E5:F5,2,FALSE),VLOOKUP(L5,H5:I5,2,FALSE)))
You can then drag the cells down to populate the date and action for every row. You could achieve the same with VBA if you wanted to, but I would have thought that this is the easiest way to get the the desired result.
I was not sure how to really create the question...
But the problem I am having is this: I have a list (in rows) that relate to a regulatory document, and after trying to create some sort of for loop or elaborate VLookUp/Index formula, I'm requesting help.
For example:
Now I want to use the rows to find the corresponding section in the document. I've already extracted and formatted the compliance document so it is in excel format.
So what I really need is this: a formula or VBA script that can
1. take the compliance number (for example 1A-1 which exist in Cell A3) and go find a cell (in single column D) that has JUST 1A-1, not 1A-1.1, not 1A-1.1.2, etc. and return it to the adjacent cell to 1A-1, for example.
Many thanks ahead of time... I am so lost!! :/
VLOOKUP vs INDEX/MATCH
You can do the 'lookup' two ways (that I'm aware of):
Using VLOOKUP:
The B3 cell contains your formula
=IF(ISERROR(VLOOKUP(A3,C:D,2,FALSE)),"",VLOOKUP(A3,C:D,2,FALSE))
where 'FALSE' is indicating there has to be an exact match and the data doesn't have to be sorted.
Using INDEX with MATCH:
The F3 cell contains the Index/Match formula
=IF(ISERROR(MATCH(A3,C:C,0)),"",INDEX(D:D,MATCH(A3,C:C,0)))
where '0' is indicating there has to be an exact match and the data doesn't have to be sorted.
INDEX/MATCH preferable!?
The MATCH function finds the position (row number if whole column is used) of the found match. This way (there's another) of using the INDEX function uses exactly this found match to return a cell's value in that position (row) in ANY specified column range (column). So they are the ideal combination.
With the VLOOKUP function you have to additionally specify the column index (range_lookup) of a range which could get complicated when the columns aren't adjacent as in this case. Most importantly, the function doesn't work if the lookup data is to the right of the match data.
VLOOKUP NOT WORKING! INDEX/MATCH STILL WORKING!
try this formula
The formula in cells
B2: =INDEX(E:E,MATCH(A2,F:F,0))
C2: =INDEX(G:G,MATCH(A2,F:F,0))
MATCH(A2,F:F,0) is finding Cell A2 in column F (0 means it will find
exact match) and will return the first row number when it would find that
INDEX(E:E,MATCH(A2,F:F,0)) will return contents of column E where row number is returned by the Match formula
I have a if formula with a number of criterias it has to match.
When I have shortened the formula down it works from beyond - IF(LEFT(A6,1)="2"
but there are no reasons it should error at this point? Any help?
=IF(LEFT(A6,2)="10","Area 1",IF(LEFT(A6,2)="12","Area 2",IF(LEFT(A6,2)="13","Area 3",IF(LEFT(A6,2)="14","Area 4",IF(LEFT(A6,2)="15","Area 5",IF(LEFT(A6,2)="16","Area 6",IF(LEFT(A6,2)="17","Area 7",IF(LEFT(A6,1)="2","Bulk",IF(LEFT(A6,1)="4","Intl",IF(LEFT(A6,2)="7","CGCC","Ad-Hoc"))))))))))
You can try combining IF and VLOOKUP.
=IF(LEFT(A6,1)="4","Intl",IF(ISNA(VLOOKUP(LEFT(A6,2),{"7","CGCC";"10","Area 1";"12","Area 2";"13","Area 3";"14","Area 4";"15","Area 5";"16","Area 6";"17","Area 7"},2,FALSE)),"Ad-Hoc",VLOOKUP(LEFT(A6,2),{"7","CGCC";"10","Area 1";"12","Area 2";"13","Area 3";"14","Area 4";"15","Area 5";"16","Area 6";"17","Area 7"},2,FALSE)))
I embedded the array in the formula but you can prepare a table (assume G1:H7) like this:
and then use the VLOOKUP with the reference:
=IF(LEFT(A6,1)="4","Intl",IF(ISNA(VLOOKUP(LEFT(A6,2),G1:H7,2,FALSE)),"Ad-Hoc",VLOOKUP(LEFT(A6,2),G1:H7,2,FALSE)))
IFNA or IFERROR could also be used but they are not available in Excel 2003.
Your entire formula could be shortened to 2 VLOOKUP functions, by putting your data into a table, with your ID column on, say, column A of sheet2, and your results column on column B of sheet2. This would look as follows:
=IFERROR(VLOOKUP(LEFT(A6,2),'Sheet2'!A:B,2,0),IFERROR(VLOOKUP(LEFT(A6),'Sheet2'!A:B,2,0),"Ad Hoc"))
What this does is: first try to match the left 2 characters in A6 to one of your ID's in column A in sheet2. If that creates an error, it tries to match the left 1 character in A6 to one of your ID's in column A of sheet2. Either way, it returns the matching value in column B of sheet2. If no match is found, it returns "Ad Hoc".
Here's what I'm looking for....
Trying to Sum the count of worksheet 'Results 2013' column G items
IF Cell A matches "Canada"
IF Cell E (date) is July
Having trouble with the date portion of the SUMIFS statement below.
SUMIFS('Results 2013'!$G$2:$G$510,'Results 2013'!$A2:$A$510
,"=Canada",'Results 2013'!$E2:$E510,MONTH('Results 2013'!$E2:$E510)=7)
Example value of "Results 2013"$E$480 is
I try this formula, and it provides back "January" which is obviously incorrect.
=TEXT(MONTH('Results 2013'!$E$480),"mmmm")
However, this formula, results in TRUE or 1
=IF(MONTH('Results 2013'!$E$480)=7,1,0)
The simplest solution is to add a column Month using the MONTH function to compute values, and then refer to this new column in SUMIFS.
This tests whether the date values in column E fall within the range 7/1/2013 and 7/31/2013. If your dates all fall within 2013, it will work.
SUMIFS('Results 2013'!$G$2:$G$510,'Results 2013'!$A2:$A$510,"=Canada",
'Results 2013'!$E2:$E510,">="&DATE(2013,7,1),
'Results 2013'!$E2:$E510,"<="&DATE(2013,7,31))
This array formula will work with the more general case of dates falling within any year:
=SUM(G2:G510*(A2:A510="Canada")*(MONTH(E2:E510)=7))
You could use an array formula , then you can use month on the entire column:
{SUM(if('Results 2013'!$A2:$A$510="Canada",1,0)*if(MONTH('Results 2013'!$E2:$E510)=7,'Results 2013'!$G$2:$G$510,0))}
just remember to use ctrl+shift+enter rather than the usual enter to finish the formula
I have a new question concerning formulas in Excel. Thing is, I have a sheet, sheet2, containing dates and values. Currently I am using a combination of the index() and match() functions in to fetch different values, according to certain conditions - one being the date, from sheet2 into another sheet, sheet1, .
The data in sheet2, will be updated from time to time wherefore certain dates in the data will obviously "disappear" and of course, yield an error in the index-match formulae, not being able to find the value at hand.
My question is then, if there is an easy way to write the formula so that if the date we try to find from sheet1 is less than the current date, transform current value into constant value. The pseudo code would be something like,
IF date_to_find from sheet1 IN sheet2 > todays_date Then
Set value to constant (do not evaluate formula)
Else
Find value in sheet2 where the dates are matched in both sheet1 and sheet2
End
I know the easiest way might be to just implement the whole thing in VBA, but just wanted to check if anyone had a nicer solution.
Current formula in sheet1 is
'A872 = "2013-05-17"
'F872 is the goal cell (containing formula)
'$A$1:$K$100 contains date in format "yyyy-mm-dd" (given as column)
'$A$2:$K$2 contains currencies (given as row)
'$A$3:$K$3 contains text (also given as row)
IFERROR(INDEX('sheet2'!$A$1:$K$100;MATCH(A872;'sheet2'!$A$1:$A$100;0);_
MATCH(1;('sheet2'!$A$2:$K$2="EUR")*('sheet2'!$A$3:$K$3="Matching text");0));"")
So, if current date is "2013-05-17", the formula evaluates perfectly and returns, say, 400.000. But tomorrow, "2013-05-18", there is no need to change the cell (2013-05-17 value has past), so I would now like to FIX this value, so that the formula doesn't try and find "2013-05-17" in sheet2 no more. I.e. I want cell F872 to just say "400.000", and not "IFERROR(INDEX(...)"
Thanks,
Niklas
You could just wrap your formula in an IF-statement like this:
=IF(A872<TODAY(),[your formula],[constant value])