Results 1 to 4 of 4

Creating an array and selective counting of numbers across columns

Threaded View

  1. #1
    Registered User
    Join Date
    10-25-2011
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    22

    Creating an array and selective counting of numbers across columns

    Hello,


    I have a spreadsheet with lots of date columns. I am trying to count 0's inbetween numbers in each row. I currently have a piece of code that will count 6 consec. 0's in a row (as 1) to help me identify patterns. It is a great start but now I need to create an array of sorts.

    I need 2 pieces. One piece is an addition to my current counting code. I would like to have it only count the 0 if the date in the date column is 5 days from a non-zero number. That is kind of hard to explain so I have tried my best in the example and I dont know if it is possible but I thought someone might know a way.

    2nd piece is I need to create an array output of sorts. This would count all consec. 0's in each row and create a horizontal list. My ideal breakdown is shown in the sample as well. The colors are simply to help explain not part of the intended result. The explanation is in Cell HD2

    Thank you so so much for your help.

    Sub ZeroCounter()
    
      lastcol = Cells(2, Columns.Count).End(xlToLeft).Column
      For i = 3 To Cells(Rows.Count, 1).End(xlUp).Row
        sixcnt = 0
        sixcnttot = 0
        For j = 2 To lastcol - 1
          If Cells(i, j) <> 0 Then sixcnt = 0
          If Cells(i, j) = 0 Then sixcnt = sixcnt + 1
          If sixcnt = 6 Then
            sixcnttot = sixcnttot + 1
            sixcnt = 0
          End If
        Next j
        Cells(i, lastcol + 1).Value = sixcnttot
        If sixcnttot >= 30 Then Cells(i, lastcol + 1).Interior.ColorIndex = 3
        If sixcnttot >= 45 Then Cells(i, 1).EntireRow.Interior.ColorIndex = 3
      
      Next i
    End Sub
    Attached Files Attached Files
    Last edited by bhenderson; 11-15-2011 at 01:35 PM. Reason: Forgot to include code

Thread Information

Users Browsing this Thread

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

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