Results 1 to 4 of 4

Counting the number of occurances with consecutive values above zero

Threaded View

  1. #4
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Counting the number of occurances with consecutive values above zero

    If your report gets too big, UDF might be a better option since it doesn't require as much memory as array formula.

    Public Function ConsecutiveOrders(ByVal PeriodRange As Range) As Integer
    Dim iCount As Integer
    Dim vPrvValue As Variant
    Dim cell As Range
    
    iCount = 0
    vPrvValue = 0
    
    For Each cell In PeriodRange
        If cell.Value <> 0 And vPrvValue = 0 Then
            iCount = iCount + 1
        End If
        vPrvValue = cell.Value
    Next cell
    
    ConsecutiveOrders = iCount
    
    End Function
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to count consecutive occurances of values greater than 0?
    By lhorner in forum Excel General
    Replies: 7
    Last Post: 05-01-2021, 11:03 AM
  2. [SOLVED] Counting maximum number of consecutive missing values
    By Moriexcel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2014, 04:45 AM
  3. [SOLVED] Counting the number of occurances
    By Losguapos1 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-05-2014, 09:41 AM
  4. Counting number of occurances matched with certain value
    By lucyscholz in forum Excel General
    Replies: 1
    Last Post: 08-31-2014, 06:07 PM
  5. Counting number of occurances in a range using VBA
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-16-2010, 12:43 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1