+ Reply to Thread
Results 1 to 5 of 5

Need macro to count rows between empty cells

  1. #1
    Registered User
    Join Date
    01-22-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Need macro to count rows between empty cells

    I have pasted an example of what I have. I need to have a macro be able to count cells from the first to the last in each set. This form varies each week, the only thing that is consistent is the first cell will always be A4. Thank you.

    6/4/2012 18:56:06
    6/4/2012 19:31:01
    6/4/2012 19:57:28
    6/4/2012 20:15:54
    6/4/2012 20:53:31
    6/4/2012 21:14:21
    6/4/2012 21:37:53
    6/4/2012 21:53:26
    6/4/2012 22:44:11
    6/4/2012 22:54:58
    6/4/2012 23:32:45
    6/5/2012 00:10:24
    6/5/2012 00:25:55
    6/5/2012 01:06:16
    6/5/2012 01:15:28
    6/5/2012 01:39:18
    6/5/2012 01:58:37
    6/5/2012 02:41:43 Need total

    6/5/2012 18:55:58
    6/5/2012 19:19:28
    6/5/2012 21:22:40
    6/5/2012 21:29:36
    6/5/2012 22:59:33
    6/5/2012 23:04:39
    6/6/2012 00:40:38
    6/6/2012 00:45:10
    6/6/2012 00:49:59
    6/6/2012 00:55:55
    6/6/2012 01:04:38
    6/6/2012 01:09:57
    6/6/2012 01:50:54
    6/6/2012 01:56:00
    6/6/2012 02:05:30
    6/6/2012 02:19:17
    6/6/2012 02:28:50
    6/6/2012 02:40:26
    6/6/2012 02:59:53 Need total

    6/6/2012 18:13:04
    6/6/2012 18:24:29
    6/6/2012 18:34:49
    6/6/2012 18:40:05
    6/6/2012 18:46:03
    6/6/2012 18:47:51
    6/6/2012 19:02:13
    6/6/2012 19:17:10
    6/6/2012 19:19:28
    6/6/2012 19:21:26
    6/6/2012 19:44:08
    6/6/2012 19:58:40
    6/6/2012 20:14:04
    6/6/2012 20:30:40
    6/6/2012 20:58:00
    6/6/2012 21:19:04
    6/6/2012 21:47:06 Need Total

  2. #2
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: Need macro to count rows between empty cells

    You cannot simply use CountA(cells) formula?

  3. #3
    Registered User
    Join Date
    01-22-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Need macro to count rows between empty cells

    I could if the entries stayed the same, but I get this weekly from several different individuals, and all of them are different, depending on how many events happened that day. Each set is a different date, with each event logged.

    TehneXus gave me the formula for hours worked each set, but I do not know how to modify it to calculate rows. Here it is if it will help.

    Sub GetTimeDiff()
    Dim i&
    Dim dStart As Date, dEnd As Date

    dStart = Cells(2, 1).Value
    For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
    If IsEmpty(Cells(i + 1, 1)) Then
    dEnd = Cells(i, 1).Value
    Cells(i, 2).Value = dEnd - dStart
    ElseIf IsEmpty(Cells(i, 1)) Then
    dStart = Cells(i + 1, 1).Value
    End If
    Next i
    End Sub

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Need macro to count rows between empty cells

    Hi,

    Try this:
    Please Login or Register  to view this content.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Registered User
    Join Date
    01-22-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Need macro to count rows between empty cells

    Thank you - worked perfectly.

+ Reply to Thread

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