Add If to beginning of indirect lookup formula

rhombus4

Well-known Member
Joined
May 26, 2010
Messages
586
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
From this threadhttp://www.mrexcel.com/forum/showthread.php?t=544974Currently have =VLOOKUP(B$2,INDIRECT("'"&A1&"'!B2:D5"),2,0)What I need is to add an If at the beginning so for example if cell C5 was blank or 0 then the result would be " or 0.i.e. something like=if(""&A1&"!c5="","",(VLOOKUP(B$2,INDIRECT("'"&A1&"'!B2:D5"),2,0))
 
Difficult to explain.I have=VLOOKUP($B$2,INDIRECT("'"&$A1&"'!B2:B5"),2,0)) If I manually enter an if below it works=IF(Sheet2!M4="","",VLOOKUP($B$2,INDIRECT("'"&$A1&"'!B2:B5"),2,0))As I have lots to copy down I want where it says Sheet2 to refer to a tab which is in column A like the vlookup looks for VLOOKUP($B$2,INDIRECT("'"&$A1&"'!B2:B5"),2,0))
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Difficult to explain.

I have =VLOOKUP($B$2,INDIRECT("'"&$A1&"'!B2:B5"),2,0))

If I manually enter an if below it works =IF(Sheet2!M4="","",VLOOKUP($B$2,INDIRECT("'"&$A1&"'!B2:B5"),2,0))

As I have lots to copy down I want where it says Sheet2 to refer to a tab which is in column A like the vlookup looks for

VLOOKUP($B$2,INDIRECT("'"&$A1&"'!B2:B5"),2,0))

Your posts are difficult to read, breaking it up a little makes it far easier to see.

Where did M4 come into things?

You asked to check C5, C6, etc so the formula I gave you was doing just that, it's not looking anywhere near M4.
 
Upvote 0
=if(indirect("'"&A1&"'!C5")="","",VLOOKUP(B2,INDIRECT("'"&A1&"'!B2:D5"),2,0))

does it work in the first row?

if you copy it down, does it work in the second row?

It works in the first row and all other rows if a number is in cell C5, although when C5 is blank it shows a 0
 
Upvote 0
in your formula =if(indirect("'"&A1&"'!C5")="","",VLOOKUP(B2,INDIRECT("'"&A1&"'!B2:D5"),2,0)) when I copy down =if(indirect("'"&A1&"'!C5")="","", the A1 changes to a2 a3 etc as it should but the C5 stays as c5 when copied down
 
Upvote 0
Try it this way instead

=if(indirect(ADDRESS(ROW(A5),3,4,,A1))="","",VLOOKUP(B2,INDIRECT("'"&A1&"'!B2:D5"),2,0))
 
Upvote 0
The formula works on the first cell when blanked but when copied down shows 0
 
Upvote 0
3 is column number (column C)
4 tells the formula to return a relative address
the extra comma skips over an optional parameter that we don't need.

If for example you have "Sheet 2" in A1, then ADDRESS(5,3,4,,A1) will return 'Sheet2'!C5

Using ROW(A5) to define the row number means it becomes relative, so when you fill down A5 changes to A6, so will be 'Sheet x'!C6, etc.
 
Upvote 0
Try it this way instead

=if(indirect(ADDRESS(ROW(A5),3,4,,A1))="","",VLOOKUP(B2,INDIRECT("'"&A1&"'!B2:D5"),2,0))

comes up with Ref# errorthis is what I have in sheet 1Tom is B1101 starts A4so the formula in the stats which equals 12 is =IF(INDIRECT("'"&$A4&"'!C2")="","",VLOOKUP($B$1,INDIRECT("'"&$A4&"'!B2:D5"),2,0)) Tom Stats Errors101 12 101801 15 1001501 15 1112201 16 1012901 19 85
 
Upvote 0
OK I now get the formula to work=IF(INDIRECT("'"&$A4&"'!C2")="","",VLOOKUP($B$1,INDIRECT("'"&$A4&"'!B2:D5"),2,0))However when you first askedIs it just C5 you want to look at for blank / 0 or the result of the VLOOKUP? I actually have other sheets which I wanted to copy down, but the results relate to the first one.i.e.c2 is okay on sheet 1 but on sheet2 needs to be c3
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top