Formula help, IF change base upon a cell.

mduntley

Board Regular
Joined
May 23, 2015
Messages
134
Office Version
  1. 365
Platform
  1. Windows
Hello, I am working on a big document. I got a formula that helps me with one column, but I am wondering if I can make this more user-friendly. This is the formula

=IF(O7="","",IF(O6="","",IF(O7=O6,"","ERROR")))

I am wondering if there is a way if I edit a cell, let say b2 that the Bold O will change. For example

b2=O
then my formula will be
=IF(O7="","",IF(O6="","",IF(O7=O6,"","ERROR")))

b2=N
then my formula will be
=IF(N7="","",IF(N6="","",IF(N7=N6,"","ERROR")))
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Either

=IF(IF($B$2="O",O7,N7)="","",IF(IF($B$2="O",O6,N6)="","",IF($B$2="O",IF(O7=O6,"","ERROR"),IF(N7=N6,"","ERROR"))))

or

=IF(INDIRECT($B$2&"7")="","",IF(INDIRECT($B$2&"6")="","",IF(INDIRECT($B$2&"7")=INDIRECT($B$2&"6"),"","ERROR")))

However, if you're going to copy these formulas down a column the 6s and 7s will change and only the first formula will work
 
Last edited:
Upvote 0
Using a letter you're forcing using INDIRECT which isn't great but will work:

Code:
=IF(AND(INDIRECT(B2&"6")<>"",INDIRECT(B2&"7")<>"",INDIRECT(B2&"6")=INDIRECT(B2&"7")),"ERROR","")

If you're prepared to use the column number instead then it's a little neater as the formula isn't volatile. You can also cut out a condition to streamline it:

Code:
=IF(AND(INDEX($6:$6,B2)<>"",INDEX($6:$6,B2)=INDEX($7:$7,B2)),"ERROR","")

Then B2 would contain 14 for "N", 15 for "O" etc.

WBD
 
Upvote 0
MAYBE TRY THIS ...

=IF(OR(INDIRECT(B2&"6")="",INDIRECT(B2&"7")=""),"",IF(INDIRECT(B2&"6")=INDIRECT(B2&"7"),"","ERROR"))

KIND REGARDS,

cHRIS
 
Upvote 0
MAYBE TRY THIS ...

=IF(OR(INDIRECT(B2&"6")="",INDIRECT(B2&"7")=""),"",IF(INDIRECT(B2&"6")=INDIRECT(B2&"7"),"","ERROR"))

KIND REGARDS,

cHRIS


This is good, but when i try to copy it down, 6 and 7 stays the same, even when i removed the "". My goal is to find any price different between two cell that has the same criteria in a different a cell.
 
Upvote 0
So I made a quick spreadsheet what my whole attention is

ABCDEFG
b
FruiteStore 1Store 2formula if f2=Bformula if f2=cformula if f2=d
Apple$ 2.00$ 2.00$ 3.00error
Orange$ 3.00$ 3.00$ 9.00ErrorERROR
Apple$ 2.00$ 2.00$ 7.00error
Orange$ 4.00ERROR
Orange$ 2.00$ 5.00ErrorERROR
Bananna$ 4.00$ 6.00$ 4.00

<tbody>
</tbody>

So this Column e-g is the result i want, but it is in one column. If a cell is blank, such as the orange in column d, 2 of them are blank so there is no error. My project is to see if there is a price difference between 2 stores, if it has a price.
 
Last edited:
Upvote 0
I *think* I understand. How about entering the store name in E1 and using a little "helper" in E2 like this:


Book1
ABCDE
1Store 1
2FruitStore 1Store 2Store 31
3Apple$2.00$2.00$2.00 
4Orange$3.00$3.00$9.00ERROR
5Apple$2.00$2.00$7.00
6Orange$4.00
7Orange$2.00$5.00ERROR
8Banana$4.00$6.00$4.00
Sheet1
Cell Formulas
RangeFormula
E2=MATCH($E1,$B$2:$D$2,0)
E3=IF(INDEX($B3:$D3,$E$2)="","",IF(SUMPRODUCT(($A$3:$A$8=$A3)*(INDEX($B$3:$D$8,,$E$2)=INDEX($B3:$D3,$E$2)))=COUNTIFS($A$3:$A$8,$A3,INDEX($B$3:$D$8,,$E$2),"<>"),"","ERROR"))


WBD
 
Upvote 0
I *think* I understand. How about entering the store name in E1 and using a little "helper" in E2 like this:

ABCDE
1Store 1
2FruitStore 1Store 2Store 31
3Apple$2.00$2.00$2.00
4Orange$3.00$3.00$9.00ERROR
5Apple$2.00$2.00$7.00
6Orange$4.00
7Orange$2.00$5.00ERROR
8Banana$4.00$6.00$4.00

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
E2=MATCH($E1,$B$2:$D$2,0)
E3=IF(INDEX($B3:$D3,$E$2)="","",IF(SUMPRODUCT(($A$3:$A$8=$A3)*(INDEX($B$3:$D$8,,$E$2)=INDEX($B3:$D3,$E$2)))=COUNTIFS($A$3:$A$8,$A3,INDEX($B$3:$D$8,,$E$2),"<>"),"","ERROR"))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



WBD


This works, thank you.
 
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

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