IF OR Formula change

julhs

Active Member
Joined
Dec 3, 2018
Messages
476
Office Version
  1. 2010
Platform
  1. Windows
There is 2 parts to my query.
1st, is there a better way to write the IF OR formula I have got in A9.
2nd, when I insert a row (in say C11) how can I ensure the formula in A9 adjusts to include the NEW row.
Because as it stands at the moment, (part of A9 formula) is:
Excel Formula:
IF(OR(A10=C7, A10=C8, A10=C9, A10=C10, A10=C11),"Supplier #1 (Spain)"
But when I insert a row in C11 the above automatically changes to:
Excel Formula:
IF(OR(A10=C7, A10=C8, A10=C9, A10=C10, A10=C12),"Supplier #1 (Spain)"
so formula is missing A10=C11

I have added a Mini sheet with a Validation List on it just to assist. HOWEVER in my real situation the VD list is in (Source)WB and that selected value would be brought into A10 by using:
Excel Formula:
A10='[Source.xlsm]Sheet1 '!$D$20
Data.xlsm
ABCD
1
2
3
4
5
6 Supplier #1 (Spain)
7Green Grapes
8Red Grapes
9Supplier #2 (Spain)Oranges
10CucumberStrawberry
11
12 Supplier #2 (Spain)
13Data Validation List = $C$6:$C$24Cucumber
14Lettice
15Tomatoes
16Green Peppers
17Red Peppers
18
19 Supplier #3 (Kenya)
20Green beans
21Kiwi
22Pomegranate
23
Sheet3
Cell Formulas
RangeFormula
A9A9=IF(A10=0,"", IF(OR(A10=C7,A10=C8,A10=C9,A10=C10,A10=C11),"Supplier #1 (Spain)", IF(OR(A10=C13,A10=C14,A10=C15,A10=C16,A10=C17,A10=C18),"Supplier #2 (Spain)",IF(OR(A10=C20,A10=C21,A10=C22,A10=C23),"Supplier #3 (Kenya)", "Check selection"))))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A9Cell Valuecontains "Check selection"textNO
A10Expression=$A$10>""textNO
A9Expression=$A$9>""textNO
C7:C23Expression=IF($A$10>"",$A$10=$C7:$C$23)textNO
Cells with Data Validation
CellAllowCriteria
A10List=$C$6:$C$22
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
What is your formula in A9 going to look like when you have 10 Suppliers? Or 100 Suppliers.

I'd put all the suppliers into one lookup table:

ABCDE
1Supplier
2Cucumber#2 (Spain)Cucumber#2 (Spain)
3Green beans#3 (Kenya)
4Green Grapes#1 (Spain)
5Green Peppers#2 (Spain)
6Kiwi#3 (Kenya)
7Lettuce#2 (Spain)
8Oranges#1 (Spain)
9Pomegranate#3 (Kenya)
10Red Peppers#2 (Spain)
11Red Grapes#1 (Spain)
12Strawberry#1 (Spain)
13Tomatoes#2 (Spain)
Sheet1
Cell Formulas
RangeFormula
B2B2=VLOOKUP(A2,Supplier,2,)
Named Ranges
NameRefers ToCells
Supplier=Sheet3!$D$2:$E$13B2

And I'd put the Supplier table somewhere I didn't need to insert or delete rows. I usually use a separate worksheet for all my tables.
 
Upvote 0
Thank you for the advice Stephen.
The list of “Suppliers” in #1 Xl2bb was only a scaled down mock-up of the actual Source WB.
In real time there are 90 rows and 30 columns in the Source WB containing additional data that is referenced by umpteen other formulas.
Redoing the layout to all that is a HUGH task and it can’t be justified, but one way or other products will need to be added to the list!

So that said; your use of VLOOKUP in A9 and the alphabetical way you listed the products gave me the idea of just adding a hidden column (D:D) containing the supplier name to my existing layout and use VLOOKUP in A9 as you suggested.
I fully except it‘s a clumsy way of doing things but it was simple enough to do and avoided the need for major redo of layout to my actual Source WB.
Many thanks for your help

Source.xlsm
ABCDE
1
2
3
4
5
6 Supplier #1 (Spain)Supplier
7Green Grapes#1 (Spain)
8Red Grapes#1 (Spain)
9#2 (Spain)Oranges#1 (Spain)
10TomatoesStrawberry#1 (Spain)
11Blueberry#1 (Spain)
12
13 Supplier #2 (Spain)
14Cucumber#2 (Spain)
15Lettice#2 (Spain)
16Tomatoes#2 (Spain)
17Green Peppers#2 (Spain)
18Red Peppers#2 (Spain)
19
20 Supplier #3 (Kenya)
21Green beans#3 (Kenya)
22Kiwi#3 (Kenya)
23Pomegranate#3 (Kenya)
24
Sheet3
Cell Formulas
RangeFormula
A9A9=VLOOKUP(A10,Supplier,2,)
Named Ranges
NameRefers ToCells
Supplier=Sheet3!$C$6:$D$23A9
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A10Expression=$A$10>""textNO
A9Expression=$A$9>""textNO
C7:C24Expression=IF($A$10>"",$A$10=$C7:$C$24)textNO
Cells with Data Validation
CellAllowCriteria
A10List=$C$6:$C$23
 
Upvote 0
You might want to consider using =VLOOKUP(A10,Supplier,2, FALSE) or =VLOOKUP(A10,Supplier,2,0) which is much clearer for most people.
Not many people will know that =VLOOKUP(A10,Supplier,2,) defaults to False but =VLOOKUP(A10,Supplier,2) without the comma defaults to True.
 
Upvote 0
So that said; your use of VLOOKUP in A9 and the alphabetical way you listed the products gave me the idea of just adding a hidden column (D:D) containing the supplier name to my existing layout and use VLOOKUP in A9 as you suggested.
Sounds like a good solution. I'm glad we could point you in the right direction.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,173
Members
453,021
Latest member
Justyna P

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