+ Reply to Thread
Results 1 to 4 of 4

Count contents in a column

  1. #1
    Forum Contributor
    Join Date
    04-12-2006
    Location
    Morgan Hill CA
    Posts
    107

    Count contents in a column

    I need to return the number of cells that contain values in a column.

    I've played with Selection.EntireColumn Select & Selection.Columns.Count but these just return the number of columns I have selected versus the number of values in those columns.

    I'm looking for the VBA code that does the spreadsheet formula "=counta(D:D)", which returns the number of values in the column "D". I don't need the values themselves, just an indication if there are any values in the first place.

    Thanks,

  2. #2
    Dave Peterson
    Guest

    Re: Count contents in a column

    msgbox application.counta(worksheets("sheet1").range("d:d"))

    is one way.

    JWM6 wrote:
    >
    > I need to return the number of cells that contain values in a column.
    >
    > I've played with Selection.EntireColumn Select &
    > Selection.Columns.Count but these just return the number of columns I
    > have selected versus the number of values in those columns.
    >
    > I'm looking for the VBA code that does the spreadsheet formula
    > "=counta(D:D)", which returns the number of values in the column "D".
    > I don't need the values themselves, just an indication if there are any
    > values in the first place.
    >
    > Thanks,
    >
    > --
    > JWM6
    > ------------------------------------------------------------------------
    > JWM6's Profile: http://www.excelforum.com/member.php...o&userid=33413
    > View this thread: http://www.excelforum.com/showthread...hreadid=534361


    --

    Dave Peterson

  3. #3
    Jim Thomlinson
    Guest

    RE: Count contents in a column

    This will count all of the populated cells in column A

    MsgBox Application.WorksheetFunction.CountA(Columns("A"))
    --
    HTH...

    Jim Thomlinson


    "JWM6" wrote:

    >
    > I need to return the number of cells that contain values in a column.
    >
    > I've played with Selection.EntireColumn Select &
    > Selection.Columns.Count but these just return the number of columns I
    > have selected versus the number of values in those columns.
    >
    > I'm looking for the VBA code that does the spreadsheet formula
    > "=counta(D:D)", which returns the number of values in the column "D".
    > I don't need the values themselves, just an indication if there are any
    > values in the first place.
    >
    > Thanks,
    >
    >
    > --
    > JWM6
    > ------------------------------------------------------------------------
    > JWM6's Profile: http://www.excelforum.com/member.php...o&userid=33413
    > View this thread: http://www.excelforum.com/showthread...hreadid=534361
    >
    >


  4. #4
    Forum Contributor
    Join Date
    04-12-2006
    Location
    Morgan Hill CA
    Posts
    107
    Seems simple enough to me and I was looking at something more complicated...

    ThanKs!

+ 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