Better Formula for sheet/range referencing

XL Pro

Board Regular
Joined
Apr 17, 2002
Messages
249
Office Version
  1. 365
Platform
  1. Windows
MyReport.XLS
ABCDE
7TotalsHOURS WORKED AT:
8ForSTRAIGHTOVERDOUBLE
9Job Class:TemplateTIMETIMETIME
10CMPCAD21E21F21
11CLICF21G21H21
12PHPJCMPCA---
13PHPJDuesCMPCA---
14JRNFUSCMPCA---
15PHFCLIC---
Totals


Column A has the sheet names
Column B has the type of template
Rows 10/11 has the type of template/ranges to reference.

the formulas in C12:E15 looks as such:
Code:
=IF(ISERROR(INDIRECT($A13&"!"&VLOOKUP($B13,$B$10:$AA$11,COLUMN(B$1),FALSE))),0,INDIRECT($A13&"!"&VLOOKUP($B13,$B$10:$AA$11,COLUMN(B$1),FALSE)))

I need to reference the cells in row 10 or 11 in the sheet in column A based on the template in column B.

Is this the best formula, or can it be better written. I'm specifically looking at the VLOOKUP() part of the formula.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
20,493
Office Version
  1. 365
Platform
  1. Windows
Maybe...

=LOOKUP(9.99999999999999E+307,CHOOSE({1,2},0,INDIRECT($A13&"!"&VLOOKUP($B13,$B$10:$AA$11,COLUMN(B$1),0))))

...which will return 0 when there's no match for VLOOKUP or when the specified sheet doesn't exist.

Hope this helps!
 

XL Pro

Board Regular
Joined
Apr 17, 2002
Messages
249
Office Version
  1. 365
Platform
  1. Windows
What's the purpose of the 9.99999999999999E+307 in the formula?
 

XL Pro

Board Regular
Joined
Apr 17, 2002
Messages
249
Office Version
  1. 365
Platform
  1. Windows
Thanks, that explains everything! :LOL:
 

Forum statistics

Threads
1,175,647
Messages
5,898,640
Members
434,719
Latest member
JoC

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
Top