calculate consecutive days

xeven_

Active Member
Joined
Jan 20, 2012
Messages
302
I have % data in column F. I want to calculate only the consecutive positive or negative days adjacently in column G as shown in the illustration, Is there a formula I can enter as I have to go back quite a number of years/days and this is very time consuming doing it manually.
Thanks in advance. ;)


[TABLE="width: 201"]
<colgroup><col width="67" style="width:51pt"> <col width="67" style="width:51pt"> <col width="67" style="width:51pt"> </colgroup><tbody>[TR]
[TD="class: xl84, width: 67"]45[/TD]
[TD="class: xl83, width: 67"]1.00%[/TD]
[TD="class: xl83, width: 67"]1.02%[/TD]
[/TR]
[TR]
[TD="class: xl84"]45[/TD]
[TD="class: xl83"]-0.46%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]45[/TD]
[TD="class: xl83"]0.38%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]45[/TD]
[TD="class: xl83"]-0.02%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]45[/TD]
[TD="class: xl83"]0.02%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]46[/TD]
[TD="class: xl83"]0.99%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]46[/TD]
[TD="class: xl83"]1.16%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]46[/TD]
[TD="class: xl83"]0.09%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]47[/TD]
[TD="class: xl83"]0.47%[/TD]
[TD="class: xl83"]2.73%[/TD]
[/TR]
[TR]
[TD="class: xl84"]47[/TD]
[TD="class: xl83"]-0.04%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]47[/TD]
[TD="class: xl83"]0.94%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]47[/TD]
[TD="class: xl83"]0.13%[/TD]
[TD="class: xl83"]1.07%[/TD]
[/TR]
[TR]
[TD="class: xl84"]45[/TD]
[TD="class: xl83"]-4.39%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]45[/TD]
[TD="class: xl83"]-0.31%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]45[/TD]
[TD="class: xl83"]-0.69%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]44[/TD]
[TD="class: xl83"]-0.90%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]44[/TD]
[TD="class: xl83"]-0.48%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]44[/TD]
[TD="class: xl83"]0.05%[/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"]44[/TD]
[TD="class: xl83"]0.50%[/TD]
[TD="class: xl83"]0.55%[/TD]
[/TR]
[TR]
[TD="class: xl84"] [/TD]
[TD="class: xl82"] [/TD]
[TD="class: xl83"] [/TD]
[/TR]
[TR]
[TD="class: xl84"] [/TD]
[TD="class: xl82"] [/TD]
[TD="class: xl83"] [/TD]
[/TR]
</tbody>[/TABLE]
 
Select cells F1:H19 (for example) and go to Conditional Formatting > New Rule where you select Use a formula. This is where you enter the formula above and then select the appropriate formatting (green in this case). Replace F1 in the formula with the first cell in your selection so, for example, if you selected F5:H100 use:

Code:
=AND(F5>0,F5<>"")

WBD
 
Upvote 0

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I have another suggestion without using the volatile function OFFSET. My suggestion does assume that there is at least one header row above the actual data.

For the values in columns G:J, try the cell formulas shown below, copied down.

For the Conditional Formatting, select from cell F2 down to K?? and enter the Conditional Formatting formulas shown.

Excel Workbook
FGHIJK
1ValueSumCountCountSumValue
20.02%    0.02%
31.00%1.02%21.00%
4-0.46%-0.46%
50.38%0.38%
6-0.02%-0.02%
70.02%0.02%
80.99%0.99%
91.16%1.16%
100.09%0.09%
110.47%2.73%50.47%
12-0.04%-0.04%
130.94%0.94%
140.13%1.07%20.13%
15-4.39%-4.39%
16-0.31%-0.31%
17-0.69%-0.69%
18-0.90%-0.90%
19-0.48%5-6.77%-0.48%
200.05%0.05%
210.50%0.55%20.50%
22
Consecutive
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F21. / Formula is =AND($F2<0,N(F2))Abc
F22. / Formula is =AND($F2>0,N(F2))Abc
 
Upvote 0
raUjgt.jpg
Peter that is just about perfect!!! Hey is there anyway to make the empty or blank cells not count when highlighting them? As it is the bottom information bar gives me the correct average but gives me a false count as in counting even the cells that are blank but contains the formula.

Thanks again (AWESOME HELP) :laugh:
 
Last edited:
Upvote 0
Peter that is just about perfect!!! Hey is there anyway to make the empty or blank cells not count when highlighting them? As it is the bottom information bar gives me the correct average but gives me a false count as in counting even the cells that are blank but contains the formula.
That is because the cells are not blank. A formula cannot leave a cell truly blank - the best it can do is put a null string ("") in it, which is what the formula does.
"Count:" at the bottom right is meant to count all cells that have anything in them, so it is giving the correct count in that regard.

Right click in that bottom right information area and you should have a choice to tick "Numerical Count" or perhaps "Count Numbers" and that should give the count that you are looking for
 
Upvote 0

Forum statistics

Threads
1,223,948
Messages
6,175,580
Members
452,653
Latest member
craigje92

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