ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Series Trending (https://www.excelbanter.com/excel-programming/347287-series-trending.html)

Bill[_30_]

Series Trending
 
Hello,
I want to know, in a series of numbers, the number of points trending in one
direction (up or down). If I reach a certain number, e.g., 7, I want to
kick out of the routine. I can do this by looping through the cells and
adding up as I go, e.g.

upcounter = 0
for icount = 1 to lastrow
if cells(icount+1,1)cells(icount,1) then
upcounter = upcounter+1
else
upcounter = 0
end if
if upcounter = 7 then goto 100
next icount


100 otherstuff

This takes a while with big data sets. Is there a way to use arrays to do
this? Or some other way?

Thanks in advance.

Bill



Tom Ogilvy

Series Trending
 
Dim v as Variant
upcounter = 0
v = Range("A1").Resize(lastRow,1).Value
for icount = 1 to lastrow
if v(icount+1,1)v(icount,1) then
upcounter = upcounter+1
else
upcounter = 0
end if
if upcounter = 7 then goto 100
next icount


--
Regards,
Tom Ogilvy


"Bill" wrote in message
ink.net...
Hello,
I want to know, in a series of numbers, the number of points trending in

one
direction (up or down). If I reach a certain number, e.g., 7, I want to
kick out of the routine. I can do this by looping through the cells and
adding up as I go, e.g.

upcounter = 0
for icount = 1 to lastrow
if cells(icount+1,1)cells(icount,1) then
upcounter = upcounter+1
else
upcounter = 0
end if
if upcounter = 7 then goto 100
next icount


100 otherstuff

This takes a while with big data sets. Is there a way to use arrays to do
this? Or some other way?

Thanks in advance.

Bill






All times are GMT +1. The time now is 10:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com