Change a formula in one cell based on the value in another cell

Posted on 2013-12-19
Last Modified: 2014-01-11
The following formula resides in column N:

I need to add a second formula in column N that references a different workbook that is very similar in structure but contains different data. The formula is as follows:

The trigger to determine which formula to use in column N is determined by the value in column V as follows:

If column V contains the phrase "Book 3", then use the SECOND formula above.
Otherwise, if column V is blank or contains any other phrase, then use the FIRST formula above.

How do I revise the current formula to meet the new requirements?

Question by:Andreamary
LVL 22

Assisted Solution

Flyster earned 250 total points
ID: 39729580
You should be able to use a IF statement for that:

IF(V1="Book 3", IFERROR(LOOKUP(2,1/('M:\aaa\[XXX_2014.xlsm]Workflow'!$H$2:$H$676=M2),'M:\aaa\[XXX_2014.xlsm]Workflow'!$J$2:$J$676),""), IFERROR(LOOKUP(2,1/('M:\xxx\[XXX_2014.xlsm]Workflow'!$H$2:$H$676=M2),'M:\xxx\[XXX_2014.xlsm]Workflow'!$J$2:$J$676),""))

Open in new window

Just change V1 to the row you need to refer to.

LVL 43

Accepted Solution

Saqib Husain, Syed earned 250 total points
ID: 39729680
Can be further reduced to

=IFERROR(LOOKUP(2,1/if(v2="Book 3",('M:\aaa\[XXX_2014.xlsm]Workflow'!$H$2:$H$676=M2),'M:\aaa\[XXX_2014.xlsm]Workflow'!$J$2:$J$676),('M:\xxx\[XXX_2014.xlsm]Workflow'!$H$2:$H$676=M2),'M:\xxx\[XXX_2014.xlsm]Workflow'!$J$2:$J$676)),"")
LVL 33

Expert Comment

by:Rob Henson
ID: 39731335
Will both source books be open at the same time as the destination book?

If so, you could use INDIRECT and pull together the file path string using IF statements creating a different string for the two different files depending on the criteria specified.

If the source books will be closed, this won't work because INDIRECT doesn't work on closed books.

Rob H

Author Comment

ID: 39732444
The source books will not always be open, but thanks for the suggestion.

I'm just implementing the formulas proposed above and should have feedback soon.


Author Closing Comment

ID: 39773365
Thanks for the prompt responses and excellent solutions!

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel TimeLine stopped working? 36 60
Text box keydown event does not work 38 40
Records from Access to Excel to specific cells 5 25
Clear a Text Box 7 24
Introduction This Article is a follow-up to my Mappit! Addin Article (, it was inspired by an email posting I made to EUSPRIG (, I will briefly cover: 1) An overvie…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question