Look Up a value on another sheet with Variable Name in Excel - excel

I have found many answers to this similar questions and yet I cannot get this formula to work.
I have a code in Cell B2 which i need to look up on another sheet. The name of this sheet is in Cell A2, and the information I need to copy is in column E of the other sheet. Here is the formula that I am trying to use however it is coming back with a #N/A Error.
=VLOOKUP($B2,INDIRECT("'"& A2 & "'!$E$1:$E$100"), 5, FALSE)
Anyone have any idea why I am not getting any information through?
Kind Regards

You need to correct the string concatenation and expand the columns so that you can return in the 5th column's information.
=VLOOKUP($B2, INDIRECT("'"& A2 & "'!A1:E100"), 5, FALSE)
In the above, B2 is looked up in column A of the lookup range (the first column in the lookup range) and the corresponding value from column E (the fifth column in the range) is returned. VLOOKUP always looks in the first column and returns the corresponding value from the column noted by the third argument but the lookup range has to have at least that many columns.
You don't need $ absolute reference markers when you are using a string to reference within INDIRECT.

If you ever feel for an Index + Match solution.
=INDEX(INDIRECT("'"& A2 &"'!$A$1:$E$100"),MATCH(B2,INDIRECT("'"& A2 &"'!$A$1:$A$100"),0),5)

Related

Check if text exist in rest of Column, and if so, use info from that row it is in

I'm after a way to a cell to check another cell that I'm inputting text into, and for it to see if that text value is the same anywhere else in the column, and if so, it grabs the number value which is in the same column as itself but in the row of the text that checked for.
So if you use picture, you can see I've currently got E7 selected. I'm wanting it to check the "GOLF COURSE" column for any other row that contains the same text it has in it's own row. For this it's "Course1". I'd like it to check through the rest of column B if there are any matches for "Course1" which there is in B3. If it matches I'm wanting it to then use the value that's in same column as it (E) but the same row as the matched text in column B. In this case I would want it to copy the value that is in E3.
If there wasn't a match (as it's a new course lets say) then I need to be able to just click on the cell and input the numbers needed, which I would be able to do anyway but just throwing it in for sake of info.
I've tried all sorts of googling and thinking how I could possibly do it but it's too difficult for my amateur knowledge of Excel.
I believe you are looking for INDEX/MATCH:
=IF(COUNTIF($B:$B,$B7)>1,INDEX(E:E,MATCH($B7,$B:$B,0)),"New")
I added a COUNTIF check to ensure that the same course exists more than once in column B, without it, you would be getting a circular reference formula (which would also happen with the above formula if the same course appears more than once, but you use this formula on the first occurrence of that course, so make sure do not use it the first time you fill out the PAR scores for a particular course).
Merged Cells Messing With INDEX/MATCH
The Formula
Copy the following formula into cell E7:
=IF(AND($B7<>"",$D7="Par"),IF(ISERROR(MATCH($B7,$B$3:$B5,0)),"Par",INDEX(E$3:E5,MATCH($B7,$B$3:$B5,0))),IF(AND($B6<>"",$D7="Strokes"),IF(ISERROR(MATCH($B6,$B$3:$B4,0)),"Strokes",INDEX(E$3:E4,MATCH($B6,$B$3:$B4,0)+1)),""))
Image
How
We are creating the formula in cell E7.
MATCH
Syntax: MATCH(lookup_value,lookup_array,match_type)
We will use MATCH to find the position of COURSE1 in the above
cells of column B.
The 1st argument is lookup_value which will be the cell in the same
row of our row (7) in column B: B7 where we will lock only the
column (we will not be searching in other columns): $B7.
The 2nd argument lookup_array will be a range. The first cell will be
cell B3 whose row and column we'll lock, because we will always
start the search from this cell in every other cell to the left or
below: $B$3. The last cell will be B5 where we will lock only the
column: $B5.
And finally we will use 0 as the parameter of the 3rd argument
match_type to find an exact match.
Now were ready to write our MATCH formula:
=MATCH($B7,$B$3:$B5,0)
Which will return 1 i.e. an exact (0) match of B7 was found
in the 1st cell of range B3:B5.
We don't want 1 (E3), but the value in the cell (5).
INDEX
The INDEX function has 2 syntaxes where we will use the 2nd:
Syntax 2: INDEX(reference,row_num,column_num,area_num)
Since were using a one-column range we can safely omit the arguments row_num and column_num, which leaves us with:
Modified Syntax: INDEX(reference,area_num)
The INDEX function used this way will return the area_num-th value
of reference i.e. in our case if area_num is 1 it will return the
1st value in our column range, if it is 2, then the 2nd, etc.
The 1st argument reference will be the same sized range of our
MATCH range in column E: $E$3:$E5 where we will remove the
column locks because we also want to return results for other
columns: E$3:E5.
The 2nd argument area_num will be our MATCH formula.
Our current formula looks like this:
=INDEX(E$3:E5,MATCH($B7,$B$3:$B5,0))
which will return the value of cell E3: 5.
Final Adjustments: IF, AND and ISERROR
That would have been almost (Error Checking) all if the cells in column B weren't merged. Therefore we have to use IF to determine if the row in which we're writing the formula contains either Par or Strokes and adjust our so far created formula for both conditions:
=IF($D7="Par",INDEX(E$3:E5,MATCH($B7,$B$3:$B5,0))
=IF($D7="Strokes",INDEX(E$3:E4,MATCH($B6,$B$3:$B4,0)+1)
=IF($D7="Par",INDEX(E$3:E5,MATCH($B7,$B$3:$B5,0)),$D7="Strokes",INDEX(E$3:E4,MATCH($B6,$B$3:$B4,0)+1))
and (3rd condition) check in column B if there is a value in the row where we're creating the formula for a row containing Par, or the row above for a row containing Strokes, using AND:
=IF(AND($B7<>"",$D7="Par"),INDEX(E$3:E5,MATCH($B7,$B$3:$B5,0)),IF(AND($B6<>"",$D7="Strokes"),INDEX(E$3:E4,MATCH($B6,$B$3:$B4,0)+1),""))
Finally we have to add some error checking, because if the match was not found the formula will produce and #N/A error:
=IF(AND($B7<>"",$D7="Par"),IF(ISERROR(MATCH($B7,$B$3:$B5,0)),"Par",INDEX(E$3:E5,MATCH($B7,$B$3:$B5,0))),IF(AND($B6<>"",$D7="Strokes"),IF(ISERROR(MATCH($B6,$B$3:$B4,0)),"Strokes",INDEX(E$3:E4,MATCH($B6,$B$3:$B4,0)+1)),""))
Now we are ready to copy the formula to the right and below as far as we need.

Update cell location in excel

I wanted to get the cell from one sheet based on cell value in other sheet
eg.
2 sheets : x,y
I want cell value from sheet "y" and its cell is "A" and column value of "A" depend on sheet x and cell B1
eg. y!A(x!$B1+1)
However,y!A gets evaluated first and I get error.
Can anyone suggest solution ?
This formula should do it:
=INDIRECT("y!r1c"&x!B1, FALSE)
This assumes x!B1 holds the column as a number
y!A(x!$B1+1)
You can use INDIRECT like Dave mentioned
y is the Sheet
A is the column
(x!$B1+1) is the row
However since you want to pickup the row part and not the column part, Dave's formula needs to be written as
=INDIRECT("y!r"&(x!B1+1)&"c1", FALSE)
Alternatively you can use OFFSET
=OFFSET(y!A1,x!B1,0)
No need to Add +1 Offset will take care of that.

Excel: Find intersection of a row and a column

My question is how can I find an intersecting cell of a specific column and row number?
My situation is this: with some calculations I find two cells, lets say B6 and E1. I know that I need a row of the first one and a column of the second one. So I could just use ROW and COLUMN functions to get the numbers. After that, I need to find an intersecting cell. Which would be E6 in this example.
I would just use INDEX(A1:Z100;ROW;COLUMN) but I don't know the exact area that I'm going to need - it depends on other stuff. I could use something like A1:XFG65000 but that is way too lame. I could also use a combination of INDIRECT(ADDRESS()) but I'm pulling data from a closed workbook so INDIRECT will not work.
If this would help to know what is this all for - here's a concrete example:
I need to find limits of a section of a sheet that I would work with. I know that it starts from the column B and goes all the way down to the last non-empty cell in this column. This range ends with a last column that has any value in first row. So to define it - I need to find the intersection of this last column and the last row with values in B column.
I use this array formula to find the last column:
INDEX(1:1;MAX((1:1<>"")*(COLUMN(1:1))))
And this array formula to find the last row:
INDEX(B:B;MAX((B:B<>"")*(ROW(B:B)))
Last column results in E1 and last row results in B6. Now I need to define my range as B1:E6, how can I get E6 out of this all to put into the resulting formula? I've been thinking for a while now and not being and Excel expert - I couldn't come up with anything. So any help would really be appreciated. Thanks!
You can use an Index/Match combination and use the Match to find the relevant cell. Use one Match() for the row and one Match() for the column.
The index/match function to find the last cell in a sheet where
column B is the leftmost table column
row 1 is the topmost table row
data in column B and in row 1 can be a mix of text and numbers
there can be empty cells in column B and row 1
the last populated cell in column B marks the last row of the table
the last populated cell in row 1 marks the last column of the table
With these premises, the following will return correct results, used in a Sum() with A1 as the starting cell and Index to return the lower right cell of the range:
=SUM(A1:INDEX(1:1048576,MAX(IFERROR(MATCH(99^99,B:B,1),0),IFERROR(MATCH("zzzz",B:B,1),0)),MAX(IFERROR(MATCH(99^99,1:1,1),0),IFERROR(MATCH("zzzz",1:1,1),0))))
Since you seem to be on a system with the semicolon as the list delimiter, here is the formula with semicolons:
=SUM(A1:INDEX(1:1048576;MAX(IFERROR(MATCH(99^99;B:B;1);0);IFERROR(MATCH("zzzz";B:B;1);0));MAX(IFERROR(MATCH(99^99;1:1;1);0);IFERROR(MATCH("zzzz";1:1;1);0))))
Offset would seem to be the way to go
=OFFSET($A$1,ROW(CELL1)-1,COLUMN(CELL2)-1)
(The -1 is needed because we already have 1 column and 1 row in A1)
in your example, =OFFSET($A$1,ROW(B6)-1,COLUMN(E1)-1) would give the value in E6
There is also ADDRESSS if you want the location: =ADDRESS(ROW(B6),COLUMN(E1)) gives the answer $E$6
The following webpage has a much easier solution, and it seems to work.
https://trumpexcel.com/intersect-operator-in-excel/
For example, in a cell, type simply: =C:C 6:6. Be sure to include one space between the column designation and the row designation. The result in your cell will be the value of cell C6. Of course, you can use more limited ranges, such as =C2:C13 B5:D5 (as shown on the webpage).
As I was searching for the answer to the same basic question, it astounded me that there is no INTERSECT worksheet function in Excel. There is an INTERSECT feature in VBA (I think), but not a worksheet function.
Anyway, the simple spacing method shown above seems to work, at least in straightforward cases.

EXCEL: Need to find a value in a range of cells from another worksheet and return value from adjacent cell

I am trying to find the formula that will search in column A (of worksheet "ABC") to find a value matching G4 in worksheet "XYZ" Once that value is found, return the value of the cell adjacent (column B of "ABC") to the cell in which this formula exists in worksheet "XYZ". All sheets are in the same workbook.
Thank you so much!
here's an example of what you're describing:
In spreadsheet ABC, you have a reference value in column A and data in column B
In spreadsheet XYZ, you have a matching number in column A. You'd like to pair the data from spreadsheet ABC to the value in XYZ:
If you notice the formula in the formula bar on the second picture, you'll see the vlookup formula to pull the data for this example. I also added an apostrophe in front of the formula in cell B1 (image 2) to have it display the formula. Note the formulas are slightly different since they point to different reference cells.
Also, here's a great reference for how the vlookup function works:
http://chandoo.org/wp/2012/03/30/comprehensive-guide-excel-vlookup/
Here is another solution that's closer to your adjusted question.
This solution still uses the vlookup formula. Instead of using it to associate a value on multiple rows, you can look-up a single value. (same function, different application)
Again, I'll point you to a great reference for how the vlookup function works:
http://chandoo.org/wp/2012/03/30/comprehensive-guide-excel-vlookup/

Excel - match data from one range to another and get the value from the cell to the right of the matched data

I'm not all that great with Excel formulas, and I'm trying to work out how to firstly check if a cell value exists in a column, and if it does, get the value of the next cell.
Specifically, I have a range of cells, from B31 to B39. What I want to do is see if those values occur in cells F3 to F12, and if they do, place the value from the cell directly to the right, ie column G3 to G12, in location D31 to D39.
I've tried IFs statements, match, VLookup and also tried solutions that I found on the net, but it keeps coming back with formula not valid. I've also tried the answer given in Stack Overflow :
Excel: check if cell value exists in column, and then get the value of
the next cell
, but I don't really understand the formula so I'm getting lost trying to convert my ranges to the formula given.
Here's the formula I'm trying to use.
=If (ISerror(Match (B31,F:F,0),"no match", Vlookup (b31,F,G,2,false)
Please can anyone help.
Put this formula in cell d31 and copy down to d39
=iferror(vlookup(b31,$f$3:$g$12,2,0),"")
Here's what is going on. VLOOKUP:
Takes a value (here the contents of b31),
Looks for it in the first column of a range (f3:f12 in the range f3:g12), and
Returns the value for the corresponding row in a column in that range (in this case, the 2nd column or g3:g12 of the range f3:g12).
As you know, the last argument of VLOOKUP sets the match type, with FALSE or 0 indicating an exact match.
Finally, IFERROR handles the #N/A when VLOOKUP does not find a match.
Here is how I used the formula from chuffs' solution:
In Sheet1, column C5, I have first names from one list and answers to a survey, but no email address. In sheet two, column A1 and C1, I have first names and email addresses, but no answers to the survey. I need email addresses and answers to the survey for my project.
With this formula I was able to get the solution as follows, putting the matched email addresses in column A1 of sheet 1.
=IFERROR(VLOOKUP(C5,Sheet1!$A$2:$C$654,3,0),"")
Thanks a bundle, guys. You are great.
I used Chuff's answer and modified it a little to do what I wanted.
I have 2 worksheets in the same workbook.
On 1st worksheet I have a list of SMS in 3 columns: phone number, date & time, message
Then I inserted a new blank column next to the phone number
On worksheet 2 I have two columns: phone number, name of person
Used the formula to check the cell on the left, and match against the range in worksheet 2, pick the name corresponding to the number and input it into the blank cell in worksheet 1.
Then just copy the formula down the whole column until last sms
It worked beautifully.
=VLOOKUP(A3,Sheet2!$A$1:$B$31,2,0)
I have added the following on my excel sheet
=VLOOKUP(B2,Res_partner!$A$2:$C$21208,1,FALSE)
Still doesn't seem to work. I get an #N/A
BUT
=VLOOKUP(B2,Res_partner!$C$2:$C$21208,1,FALSE)
Works

Resources