+ Reply to Thread
Results 1 to 3 of 3

Macro for Counting the number of records in a worksheet

  1. #1
    Sri Ram
    Guest

    Macro for Counting the number of records in a worksheet

    I need to count the number of records in worksheet leaving the empty rows
    using VBA code.Is there anyway to do it?

  2. #2
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    hi

    Assuming the data is in column A

    Sub test()
    rowcount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
    MsgBox rowcount
    End Sub

  3. #3
    Alf Bryn
    Guest

    Re: Macro for Counting the number of records in a worksheet

    If you just want to count cells with values in column A you could do like
    this:

    Sub Test()
    Dim iLastRow As Long
    Dim i As Long

    Range("C3").Value = 0

    iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 1 To iLastRow
    If Cells(i, "A").Value <> "" Then
    Range("C3").Value = Range("C3").Value + 1
    End If
    Next i

    End Sub



    "jetted" <[email protected]> wrote in
    message news:[email protected]...
    >
    > hi
    >
    > Assuming the data is in column A
    >
    > Sub test()
    > rowcount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
    > MsgBox rowcount
    > End Sub
    >
    >
    > --
    > jetted
    > ------------------------------------------------------------------------
    > jetted's Profile:
    > http://www.excelforum.com/member.php...o&userid=17532
    > View this thread: http://www.excelforum.com/showthread...hreadid=558896
    >




+ 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