Struggling with an IF Query

martnarts

New Member
Joined
Aug 8, 2016
Messages
1
I have the following data

ABCDEF
16681.076695.216680.586695.13RED
26678.156681.066677.226681.06RED
36674.46678.886673.576678.13RED
46678.366679.546674.076674.31GREEN
56677.786678.586677.586678.25RED

<tbody>
</tbody>

I want cell F2 and the rest of the column to calculate the following formula:
=IF(E1="RED",D2-A2,A2-D2)

However I also want the cell to calculate if the preceding cell above it is greater than ZERO then do not calculate the =IF(E1="RED",D2-A2,A2-D2) formula and just leave a blank cell. I have come up with this but it does not work
=IF(F1>0,"",E1="RED",D2-A2,A2-D2)

When I copy this down the moment a cell is greater than 0 the following cells underneath are blank when I only want to do it for the next cell.

Hope this is making sense in short if the above cell calculation creates a figure >0 then do not do the calculation for the next cell, start again with the cell below so it would look something like this...

ABCDEF
16681.076695.216680.586695.13RED
26678.156681.066677.226681.06RED2.91
36674.46678.886673.576678.13RED
46678.366679.546674.076674.31GREEN-0.05
56677.786678.586677.586678.25RED-0.47

<tbody>
</tbody>

I'm happy to create new columns if need be.

Thanks for the help in advance!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Is this what you are after?


Excel 2010
ABCDEF
1Header1Header2Header3Header4Header5Header6
26681.076695.216680.586695.13RED14.06
36678.156681.066677.226681.06RED0
46674.46678.886673.576678.13RED3.73
56678.366679.546674.076674.31GREEN0
66677.786678.586677.586678.25RED0.47
Sheet1
Cell Formulas
RangeFormula
F2=IF(AND(F1>0,NOT(ISTEXT(F1))),0,IF(E2="RED",D2-A2,A2-D2))
 
Upvote 0
header1header2header3header4header5header6
6681.076695.216680.586695.13RED14.06
6678.156681.066677.226681.06RED#######
6674.46678.886673.576678.13RED3.73
6678.366679.546674.076674.31GREEN
6677.786678.586677.586678.25RED0.47
######cell F3
=IF(F2="",IF(E3="RED",D3-A3,A3-D3),IF(F2>0,"",IF(E3="RED",D3-A3,A3-D3)))

<colgroup><col width="64" span="12" style="width:48pt"> </colgroup><tbody>
</tbody>
 
Upvote 0
comfy - amazing coincidence we both thought headers would help and both used header not heading - I put them in th sort out F2....
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,865
Members
449,052
Latest member
Fuddy_Duddy

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