Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

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

Posted on 2013-12-19
Medium Priority
258 Views
The following formula resides in column N:
=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),"")

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:
=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),"")

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?

Thanks!
Andrea
0
Question by:Andreamary
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 22

Assisted Solution

Flyster earned 1000 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),""))
``````
Just change V1 to the row you need to refer to.

Flyster
0

LVL 43

Accepted Solution

Saqib Husain, Syed earned 1000 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)),"")
0

LVL 33

Expert Comment

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.

Thanks
Rob H
0

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.

Andrea
0

Author Closing Comment

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

## Featured Post

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.