Data Cycles Macro

RyanITSC

New Member
Joined
Feb 3, 2015
Messages
5
Hello all,

I am trying to create a macro that would cycle thru some data and give me a count of how many cycles are in this data set.

Here is some psuedo code that I created but don't know where to start after this.

Loop through data in column B until cell >= .0008

Then

MyRange = current cell Col B+ next 169 cells of Col B

Average of Range
*****
Oh and start the loop at row 1473 where column A = 2360, end loop where column A = 17010

I also need to count the number of times the value exceeds .0006 in the range.

If anyone could either create this or help me out on this I would greatly appreciate it.


Thank you!
Ryan
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Maybe try something like this:



Code:
[COLOR=#0000ff]Option Explicit
[/COLOR]
[COLOR=#0000ff]Sub [/COLOR]Test()[COLOR=#0000ff]
[/COLOR]
[COLOR=#0000ff]    Dim[/COLOR] Cll [COLOR=#0000ff]As [/COLOR]Range
[COLOR=#0000ff]    Dim[/COLOR] LastRow [COLOR=#0000ff]As Long[/COLOR]
[COLOR=#0000ff]    Dim[/COLOR] AvgRng [COLOR=#0000ff]As Double[/COLOR]
[COLOR=#0000ff]    Dim[/COLOR] Start [COLOR=#0000ff]As Long[/COLOR]

    LastRow = Range("B" & Rows.Count).End(xlUp).Row
    
[COLOR=#0000ff]    For Each[/COLOR] Cll [COLOR=#0000ff]In [/COLOR]Range("B2:B" & LastRow)[COLOR=#008000] 'If you want to start at 1473 Change To Range("B1473:B" & LastRow)[/COLOR]
    [COLOR=#0000ff]   If[/COLOR] Cll.Value >= 0.0008 [COLOR=#0000ff]Then[/COLOR]
            Start = Cll.Row
            AvgRng = Application.WorksheetFunction.Average(Range(Cells(Start, "B"), Cells(Start + 169, "B"))) [COLOR=#008000]'Or Use Range ("B" & Start & ":B" & Start + 169)[/COLOR]
[COLOR=#0000ff]            Exit For[/COLOR]
[COLOR=#0000ff]       End If[/COLOR]
  [COLOR=#0000ff]  Next[/COLOR] Cll
    
    MsgBox Format(AvgRng, "0.00000")

[COLOR=#0000ff]End Sub[/COLOR]

You can also use

Code:
OtherVariable = Application.WorksheetFunction.Countif([COLOR=#ff0000]Your Expression[/COLOR])

For your question regarding numbers over .0006 in your range....
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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