Count negative values before first positive

loudnoiseman

Board Regular
Joined
Dec 31, 2004
Messages
218
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I'm doing some amateur stock analysis and have a system set up to return price gains/losses 100 days forward in time based on various factors of pressure looking 100 days back.

My B column lists forward looking positive/negative values and columns C thru L are backward looking factor values and I need a formula in $M$1 that will count how many negatives appear in B column before the first positive, each time I sort factor columns.

I need to repeat a zillion times with macros so I think this solution will greatly speed up many weeks worth of work.

Thanks so much!!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
MrExcelPlayground6.xlsx
BCDEFGHIJKLM
1Column7
2-10
3-9
4-8
5-7
6-6
7-5
8-4
93
10-1
11-1
12-1
13-1
142
153
164
175
186
197
208
219
2210
2311
2412
2513
2614
Sheet10
Cell Formulas
RangeFormula
M1M1=MIN(IF(IF(B2:B26<0,1,0)=0,ROW(B2:B26)-ROW(B2),""))
 
Upvote 0
Solution

Forum statistics

Threads
1,215,034
Messages
6,122,782
Members
449,095
Latest member
m_smith_solihull

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