Formula help, IF change base upon a cell.

mduntley

Board Regular
Joined
May 23, 2015
Messages
139
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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
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

[TABLE="class: grid, width: 462"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]b[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Fruite[/TD]
[TD]Store 1[/TD]
[TD]Store 2[/TD]
[TD][/TD]
[TD]formula if f2=B[/TD]
[TD]formula if f2=c[/TD]
[TD]formula if f2=d[/TD]
[/TR]
[TR]
[TD]Apple[/TD]
[TD]$ 2.00[/TD]
[TD]$ 2.00[/TD]
[TD]$ 3.00[/TD]
[TD][/TD]
[TD][/TD]
[TD]error[/TD]
[/TR]
[TR]
[TD]Orange[/TD]
[TD]$ 3.00[/TD]
[TD]$ 3.00[/TD]
[TD]$ 9.00[/TD]
[TD]Error[/TD]
[TD]ERROR[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Apple[/TD]
[TD]$ 2.00[/TD]
[TD]$ 2.00[/TD]
[TD]$ 7.00[/TD]
[TD][/TD]
[TD][/TD]
[TD]error[/TD]
[/TR]
[TR]
[TD]Orange[/TD]
[TD][/TD]
[TD]$ 4.00[/TD]
[TD][/TD]
[TD][/TD]
[TD]ERROR[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Orange[/TD]
[TD]$ 2.00[/TD]
[TD]$ 5.00[/TD]
[TD][/TD]
[TD]Error[/TD]
[TD]ERROR[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Bananna[/TD]
[TD]$ 4.00[/TD]
[TD]$ 6.00[/TD]
[TD]$ 4.00[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

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
Store 1
FruitStore 1Store 2Store 3
Apple
OrangeERROR
Apple
Orange
OrangeERROR
Banana

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]1[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]$2.00[/TD]
[TD="align: right"]$2.00[/TD]
[TD="align: right"]$2.00[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]$3.00[/TD]
[TD="align: right"]$3.00[/TD]
[TD="align: right"]$9.00[/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]$2.00[/TD]
[TD="align: right"]$2.00[/TD]
[TD="align: right"]$7.00[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"][/TD]
[TD="align: right"]$4.00[/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]

[TD="align: right"]$2.00[/TD]
[TD="align: right"]$5.00[/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]

[TD="align: right"]$4.00[/TD]
[TD="align: right"]$6.00[/TD]
[TD="align: right"]$4.00[/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]E2[/TH]
[TD="align: left"]=MATCH($E1,$B$2:$D$2,0)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]E3[/TH]
[TD="align: left"]=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"))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]



WBD


This works, thank you.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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