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]
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
YrCxKH.jpg
 
Upvote 0
It isn't clear to me.

1. In post 2, are you trying to calculate the figures in column G, or column H, or both?

2. In your original post you mentioned consecutive positive or negative, but your screen shot only seems to be about positives. Please clarify.

3. Would it matter if the single positive (or negative) value rows were also calculated?
 
Upvote 0

Excel 2016 (Windows) 32 bit
FGH
11.00%  
2-0.46%
30.38%
4-0.02%
50.02%
60.99%
71.16%
80.09%
90.47%2.73%5
10-0.04%
110.94%
120.13%1.07%2
13-4.39%
14-0.31%
15-0.69%
16-0.90%
17-0.48%
180.05%
190.50%0.55%2
Sheet1
Cell Formulas
RangeFormula
G1=IF($H1="","",SUM(OFFSET($F1,1-$H1,0,$H1)))
H1=IF($F1<0,"",IF(OR($F2<0,$F2=""),IF(ROW()>1,IF(OFFSET($F1,-1,0)<0,"",ROW()-LOOKUP(2,1/($F$1:$F1<0),ROW($F$1:$F1))),""),""))


WBD
 
Last edited:
Upvote 0
Peter..yes I should have been more precise. Primarily calculate the clustered percent changes in G and the days in H as shown in the screen shot. I want to do the negatives as well but on the right hand side of the page. so the final hoped for result will be able to do this. See screen shot below:
Jpv1SE.jpg
 
Last edited:
Upvote 0
Wideboydixon that is awesome. :laugh:

Hey I tried to color code it via the conditional formatting and it it turning even my empty cells green. I wonder if there is a ways to make it not do that?
S1U2v9.jpg
 
Upvote 0
Also it is tallying/counting all highlighted cells.Is there a way to make it not do that? See screenshot:
1l65gx.jpg
 
Upvote 0
Select a contiguous range and use a formula to format the cells. For example, I selected $F$1:$H$19 and used this formula:

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

WBD
 
Upvote 0

Forum statistics

Threads
1,223,948
Messages
6,175,570
Members
452,652
Latest member
eduedu

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