Excel/rewriting formula

Advertisement


Question
QUESTION: Hi Tom

Hope you enjoyed your break.  Tom I would like to rewrite the following formula:

=IF($D4="","",INDEX(INDIRECT("PON!2:662"),MATCH($D4,PON!$A$2:$A$662,0),MATCH(E$3,PON!$1:$1,0)))

It tries to match a reference "D4" with information in a source workbook "PON".  If the reference does not match with anything in source "PON", I would like the formula to refer to up to four other sources: "PON2", "PON3", "PON3" and "PON4".  Is this possible?

Thanks

Chris Mitchell

ANSWER: Christopher Mitchell
>"PON2", "PON3", "PON3" and "PON4".  

I assume you mean
"PON2", "PON3", "PON4" and "PON5"  

=IF($D4="","",IFERROR(INDEX(INDIRECT("PON!2:662"),MATCH($D4,Pon!$A$2:$A$662,0),MATCH(E$3,Pon!$1:$1,0)),IFERROR(INDEX(INDIRECT("PON2!2:662"),MATCH($D4,'Pon2'!$A$2:$A$662,0),MATCH(E$3,'Pon2'!$1:$1,0)),IFERROR(INDEX(INDIRECT("PON3!2:662"),MATCH($D4,'Pon3'!$A$2:$A$662,0),MATCH(E$3,'Pon3'!$1:$1,0)),IFERROR(INDEX(INDIRECT("PON4!2:662"),MATCH($D4,'Pon4'!$A$2:$A$662,0),MATCH(E$3,'Pon4'!$1:$1,0)),IFERROR(INDEX(INDIRECT("PON5!2:662"),MATCH($D4,'Pon5'!$A$2:$A$662,0),MATCH(E$3,'Pon5'!$1:$1,0)),"No Match"))))))

--
Regards,
Tom Ogilvy


---------- FOLLOW-UP ----------

QUESTION: Hi Tom

Couldn't resist it.  I tried the formula that you rewrote.  When placed in cells it attempts to open another workbook. "PON" "PON2", "PON3" "PON4" and "PON5" are all sheets in the same workbook.  Does this make a difference?

Chris Mitchell

Answer
Chris Mitchell

I would suggest you don't have one of the cited sheet names.  Perhaps it appears you do but I would suggest at least one has a space preceding or after the name.

example, instead of "PON4"  you might have " PON4"  or "PON4 "

a further complication is that PON2, PON3, PON4 and PON5 are all legitimate cell references.  So that could cause confusion and you see in my formula that Excel enclosed the names in single quotes.  They are not enclosed by single quotes in the INDIRECT function, but that caused no problem for me.

This is a version with single quotes in the indirect - but like I said, that wasn't necessary for me in Excel 2010

=IF($D4="","",IFERROR(INDEX(INDIRECT("'PON'!2:662"),MATCH($D4,Pon!$A$2:$A$662,0),MATCH(E$3,Pon!$1:$1,0)),IFERROR(INDEX(INDIRECT("'PON2'!2:662"),MATCH($D4,'Pon2'!$A$2:$A$662,0),MATCH(E$3,'Pon2'!$1:$1,0)),IFERROR(INDEX(INDIRECT("'PON3'!2:662"),MATCH($D4,'Pon3'!$A$2:$A$662,0),MATCH(E$3,'Pon3'!$1:$1,0)),IFERROR(INDEX(INDIRECT("'PON4'!2:662"),MATCH($D4,'Pon4'!$A$2:$A$662,0),MATCH(E$3,'Pon4'!$1:$1,0)),IFERROR(INDEX(INDIRECT("'PON5'!2:662"),MATCH($D4,'Pon5'!$A$2:$A$662,0),MATCH(E$3,'Pon5'!$1:$1,0)),"No Match"))))))

So to summarize, I tested it before posting and had no such experience as you describe - thus in conjunction with your description, I believe you don't have matching sheet names in at least on sheet.

--
Regards,
Tom Ogilvy  
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Tom Ogilvy

Expertise

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

Experience

Extensive experience.

Education/Credentials
Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 About.com. All rights reserved.