I'm testing the VLOOKUP function with different sheets. I have created a sheet1 as my data reference table and sheet2 as where data is supposed to be filled with reference to the Name. I just don't know what is wrong with the formula. It keeps giving the #ref!.
Below is the formula that I'm using.
=VLOOKUP(A2,Sheet1!$A$2:$A$6,2,FALSE)
SHEET1
SHEET2
The 2nd argument should include the ID column from Sheet1. Like below:
=VLOOKUP(A2,Sheet1!$A$2:$B$6,2,FALSE)
The way Vlookup works is - it looks for the value of A2 in the first column in $A$2:$B$6 and returns the 2nd column with Exact Match (FALSE)
So if you change the 3rd argument(2) to 3, then the range should have a minimum of 3 columns like $A$2:$C$6
You can try change argument 4th to 0 and change $A$2:$A$6 to $A$2:$B$6
=VLOOKUP(A2,Sheet1!$A$2:$B$6,2,0)
#REf occurs when your reference is not valid .See ,You referenced $A$2:$A$6,It is not valid ,As your array in sheet1 is extended to B6 .
Use this:=VLOOKUP(A2,Sheet1!$A$2:$B$6,2,FALSE)
Related
I am having trouble with an Excel-function.
On sheet A I want to get the value of a cell that is located x-columns to the right of cell F2.
X is a variable number and is determined by the value of cell A1. Currently, the value is 5.
=(OFFSET(sheetA!F2,0,sheetA!A1))
This formula works. However, I want to include this function into a MATCH and INDEX function that is located on another sheet (B).
I know that I can use the following formula to get value of $F$2
INDEX(sheetA!F:F,MATCH(sheetB!C4,sheetA!A:A,0))
Combining them, results in the following formula:
=INDEX((OFFSET(sheetA!F2,0,sheetA!A1)),MATCH(sheetB!C4,sheetA!A:A,0))
This formula generates a #REF!-value.
If I evaluate the formula, I see the following steps:
=INDEX((OFFSET(sheetA!$F$2,0,5)),MATCH(sheetB!C4,sheetA!A:A,0))
=INDEX((sheetA!$K$2),MATCH(sheetB!C4,sheetA!A:A,0))
=INDEX((sheetA!$K$2),MATCH("BTC",sheetA!A:A,0))
=#REF!
Why do I want to use MATCH and INDEX?
Because while the values on sheet A are "fixed", the values of sheetB!C4 are floating/variable. Therefore, I need to locate the correct row first. The correct column can be done with the offset-part.
Thank you for your help.
Try this
=INDEX((OFFSET(SheetA!F:F,0,SheetA!A1)),MATCH(SheetB!C4,SheetA!A:A,0))
Syntax of INDEX is
INDEX(array, row_num, [column_num])
where, array is range of cells. When you use =INDEX((OFFSET(sheetA!F2,0,sheetA!A1)),MATCH(sheetB!C4,sheetA!A:A,0)), (OFFSET(sheetA!F2,0,sheetA!A1)) returns sheetA!$K$2 which is a cell not a range.
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".
I have this formula in excel, to return a row number:
=MATCH(INDIRECT(ADDRESS(ROW(),4)),DayOffRequests!$A$1:$A$100,0)
and it works just fine.
I would like to make a new name (DAYS_OFF_ROW) and assign it to this formula.
Here's what I did in the name manager:
But when I write this into a cell: =DAYS_OFF_ROW it says #VALUE! whereas when I write the same formula into the cell, it gives me the row number I am looking for.
Why is does it say #VALUE! and not the row number like the formula does?
First off Row() returns the row on which the cell resides. If you put Row() in indirect you will get an error since there is no cell for which Excel can find a Row(). So right off the bat, your formula is nonsense for a named range.
Second, even if there was some magic way for Excel to know which Row() you cared about here, Match doesn't return a range. Just a position in an array like "5" or "50". When you use a formula to define a named range, the result of the formula MUST be a range. So you could do another Indirect like =Indirect("A" & Match(foo,bar)) or something so that the result out of your formula actually refers to a range in your sheet.
It works if i set the name to this formula: =MATCH(!$D1,DayOffRequests!$A$1:$A$100,0)
Of course i have to be in field A1 when setting the name. Now its reference the fourth column and whichever row i am in.
I'm have an excel workbook Spreadsheet.xlsx in which B2=MATCH(B1,'\\SERVER\Path\To\File\[Workbook.xlsx]Sheet1'!$A$1:$A$500,0) takes the string (a name) in in B1 and matches it to a column of row headers in Workbook.xlsx, to give the row number.
Currently B2 returns a value of 8, which is used in B3=INDEX('\\SERVER\Path\To\File\[Workbook.xlsx]Sheet1'!$A$8:$SD$8), MATCH($A4,'\\SERVER\Path\To\File\[Workbook.xlsx]Sheet1'!$A$2:$SD$2,0)).
B3 indexes a range of values $A$8:$SD$8 corresponding to the row number from B2 in Sheet1 in Workbook.xlsx, and returns the values matched to a date $A4 in the range $A$2:$SD$2.
Currently I am manually typing in the row number to B3 range `$A$8:$SD$8.
If I try to automate this using B3=INDEX(INDIRECT("'\\SERVER\Path\To\File\[Workbook.xlsx]Sheet'!$A$"&B2&":$SD$"&B2), MATCH($A4,'\\SERVER\Path\To\File\[Workbook.xlsx]Sheet1'!$A$2:$SD$2,0)), I get a #REF error.
I have used INDIRECT elsewhere e.g. =MAX(INDIRECT(K&"K1")) and it has worked just fine.
Also, Workbook.xlsx and Sheet1 in it definitely exist, and I am able to get data from them without using INDIRECT.
Why doesn't it work?
INDEX and MATCH functions, as used here, do work with closed workbooks - INDIRECT doesn't
...but you don't really need INDIRECT here - you can use this version with B2 defining the row number in the first range
=INDEX('\\SERVER\Path\To\File\[Workbook.xlsx]Sheet1'!$A$1:$SD$500),B2, MATCH($A4,'\\SERVER\Path\To\File\[Workbook.xlsx]Sheet1'!$A$2:$SD$2,0))
That should work even if the source workbook is closed, and is a "cleaner", more robust approach in any case.
Note that the first range in the formula is changed to be as long as your match range from B2
If you want you can cut out B2 altogether, just put the MATCH function from B2 in that formula in place of B2, i.e.
=INDEX('\\SERVER\Path\To\File\[Workbook.xlsx]Sheet1'!$A$1:$SD$500),MATCH(B1,'\\SERVER\Path\To\File\[Workbook.xlsx]Sheet1'!$A$1:$A$500,0), MATCH($A4,'\\SERVER\Path\To\File\[Workbook.xlsx]Sheet1'!$A$2:$SD$2,0))
[Note: as Jerry mentioned, your sheet names weren't consistent so I changed the first to Sheet1 to match the others]
I'm trying to use offset to link two sheets in a work book
I am in Sheet2
If I type ='Sheet1'!B6 .... it gives me B6 from Sheet1
If I type +OFFSET('Sheet1'!B6,0,ROW()).... it gives me L6 from Sheet1
Why does it not pick up B6?
If I drag down the second formula it gives me M6,N6,O6,P6 etc, so it's at least consistent.
I've tried everything I can think of to get it to refer to the proper cell but to no avail. It's frustrating as I could have typed the data in by now!
Try
=OFFSET('Sheet1'!B6,0,0)
The "Row()" function is returning a value that is pushing the Offset 11 columns to the right.
Your mistake is you have ROW() in place of column argument ? The 3rd argument in OFFSET is column number and not row number.
Try :
=OFFSET(Sheet1!B6,0,0)
In OFFSET, 0 Row and 0 column means it is the same co-ordinate as the current referenced cell. That is, from Sheet1!B6 increase/decrease 0 rows & 0 columns.
I Have found a solution!!
If I create another column say B in Sheet2 and fill it with 1,2,3,4 etc.I can use the formula like this:-
=OFFSET('Outside funds'!$B$6,0,(B10-1))
It picks up everything correctly.
It may not be the best solution but it works.
Thanks for your help.
To transpose columns to rows, try
=OFFSET('Sheet1'!$B$6,0,ROW()-1)
The second offset parameter is the row offset, the third is the column offset. Make sure to anchor the first parameter otherwise you'll double the offset when you copy down.