Results 1 to 3 of 3

Counting non-empty cells

Threaded View

Phosphonothioic Counting non-empty cells 10-09-2009, 10:19 PM
Leith Ross Re: Counting non-empty cells 10-09-2009, 10:52 PM
royUK Re: Counting non-empty cells 10-10-2009, 03:42 AM
  1. #1
    Registered User
    Join Date
    09-27-2009
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2003
    Posts
    23

    Counting non-empty cells

    I need to count the number of cells in a column and return that number as a variable to be use in a later function.

    -The function will need to accept an input as to where to start counting.

    Example: I need it to start counting at A26 vs. A1. The starting point will vary on my spreadsheet, but I already have a function that returns the row number of the particular starting point I'm looking for.

    -Upon receiving that starting row from a call to a proceeding function, the function needs to output the number of non-empty cells it encounters in column A1 before it hits an empty cell. When it reachs an empty cell for the first time, it needs to end the loop and spit out the number of non-empty cells it found.

    I understand the general architecture of the program I need, just am not familiar with the MS VB enough to get the coding right.


    I've stumbled around a bit and put together the following:
    Function Count(Number) As Integer
    
    Dim Total
    Dim nRow
    
    Total = 0
    
    For nRow = 2 + FindRow("Part-Time") To Worksheets("Attendance Record 0726-0801").??Columns(nCol).Rows.Count?? <--Not sure how to format.  Should be column A1 and all rows.
    
    If Not IsEmpty(Worksheets(HOS).Cells(nRow, 1)) Then
        Total = Total + 1
        nRow = nRow + 1
    Else
         End If
    
    End Function
    It horrible and not well thought out, I know. But the spirit of what I want to do it in there. I know I need a FOR loop, with the IF testing each cell to see if it's empty. Each time it finds a 'full' cell, it steps the value of Total (the variable to be used later) and steps nRow, then it needs to restart the loop.

    Like I said, not good with the coding, but the general outline is there. Please help!
    Last edited by Leith Ross; 10-09-2009 at 10:50 PM. Reason: Added Code tags

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