Concerning formula issue - excel

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])

Related

Vlookup with specific date showing N/A

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.

VBA: vlookup through multiple columns

this is my first question so I will try my best to format this.
I would like to use the vlookup function in more than just one column. It seems impossible to do is in the formula for the large data set, so maybe someone with VBA knowledge can help me.
In my excel file I've two spreadsheets:
Sheet1 with one column "A" with 16868 different processes ID's.
Sheet2 with columns from "A" to "HX", where "A:HW" are different processes ID's (each column have different numbers of rows) and in "HX" column I have a region for the particular row of processes.
What I am trying to achieve is to do vloop for sheet1 column "A" that will look for each record in table sheet2 and return "HX" when found it.
In example:
I'm looking for "A2" cell in sheet1 in table_array sheet2 "A:HX". If found it then return cell in the same row but from column "HX". The trick here is when the looking value is not in the sheet2 column "A", then it should vlookup in column "B", then "C" and so on till "HW". There is an option where the looking value might not be in sheet2 at all and then the formula should return "0".
Is it possible to do this in VBA or excel formula?
Firstly, please NEVER use VLOOKUP. Ever.
An INDEX/MATCH combination is always better in every way. It is faster, more flexible and more robust as it does not break if you insert columns. It is also (arguably) easier to use as you do not need to count columns.
Anyway, back to the problem at hand. You can use an INDEX/SUMPRODUCT combination for this:
=INDEX(<range of return values>),SUMPRODUCT(--MAX((<range to search in>=<value to search for>)*ROW(<range to search in>)))-(ROW(<range to search in>)-1))
The SUMPRODUCT returns the last row number where the value is found.
The last bit -(ROW(<range to search in>)-1) is just to make the returned value relative to the searched range (rather than an absolute row number.
The INDEX is then uses this value to select a value from the HX column.

Excel VBA/Formula to find a cell that includes search term?

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

Excel - Check if value X and value Y is on the same row

I have an excel document with two sheets, data and edu-plan. The sheet data has the following information:
The sheet edu-plan looks like this:
My question is: how do i create an excel formula that checks if the target group on the specific row in edu-plan! has the course name in question on the same row as the target group in sheet data!, i.e. if Sales and Sales course is on the same row in the sheet data!?
In reality, the data sheet as a couple of hundred rows and will change over time, so i am trying to develop a formula that i can apply easily on all rows/columns in edu-plan!.
The desired result in edu-plan would look like this:
A pivot table might be a good way to go.
If you would like to do it by formula, then you can just use a COUNTIFS
=IF(COUNTIFS(data!$A$2:$A$10,$A2,data!$B$2:$B$10,B$1),"X","")
A possible way to solve your issue with an array formula:
Write in B2 of sheet edu-plan
{=IFERROR(IF(MATCH('edu-plan'!$A2&'edu-plan'!B$1,data!$A$2:$A$6&data!$B$2:$B$6,0)>0,"x",""),"")}
Since it is an array formula, you need to hit shift + ctr + enter.
Here is the formula broken down:
MATCH('edu-plan'!$A2&'edu-plan'!B$1,data!$A$2:$A$6&data!$B$2:$B$6,0)
checks whether the combination of row header and column header is in the data table. MATCH returns the index of the found combination. Since we are not interested in the location, we only ask IF(MATCH > 0, "x", "") to write an "x" if a match was found. If MATCH finds nothing, it returns an error, which is why we add an IFERROR(VALUE, "") around the construct.

How to use VLOOKUP in this situation?

Here's what I'm trying to do with no success.
I have 2 sheets in a workbook. Format and TC.
Format looks something like this:
And TC looks something like this
I want to add after the last column in Format another column where to add the values that are in the 10th column of the TC value. That if the 2nd columns in both are the same.
This is how I tried to do it and it seems it doesn't work and I really don't know why since I'm an absolute beginer with VLOOKUP.
=IF(VLOOKUP(B2;TC!B:B;TC!V:V;FALSE)= "Montaj (Montage)"; "here I want to select the time and I don't know how…"; "VALUE NOT FOUND")
To explain it better... if the value of one cell in column 2(B) in the Format sheet is found in TC sheet in column 2(or B) then if the value of the 4th column (V) is "Montaj (Montage)" I want to put the value in the 10th column (235 in the example).
Thanks a lot for your help!
FINAL UPDATE: Added explanation.
What you need is SUMIFS. I fixed this to match your comment below.
=SUMIFS(TC!Z:Z,TC!B:B,Format!B2,TC!J:J,"Montaj (Montage)")
This will look in the B column in the TC sheet and look for the value in B2 of the Format sheet. If it finds it, AND it finds "Montaj (Montage)" in the same row in the J column, then it will return(sum if there are more than one match) value in the SAME ROW in the J column.
SUMIF is really convenient for summing conditions like this. If you only have 1 condition, you can use SUMIF. VLookup is similar, but it just returns a single value, it doesn't do anything with it.
Here is some helpful info on how SUMIFS works: http://office.microsoft.com/en-us/excel-help/sumifs-function-HA010047504.aspx

Resources