+ Reply to Thread
Results 1 to 4 of 4

COUNTA Function in VBA

  1. #1
    Registered User
    Join Date
    11-16-2006
    Posts
    80

    COUNTA Function in VBA

    Hi All,

    I have a column with dates (UK format). What I want to do is select a range in that columns and count the number there are, i.e:

    Column A

    01/03/2007
    02/03/2007
    03/03/2007
    04/03/2007
    05/03/2007

    Say I select rows 2 to 3 in column A, when I run the macro I want a msgBox to return, "You selected 3". This is what I have:

    Please Login or Register  to view this content.
    My problem is, that the function keeps returning 1, no matter how many I select. I have attached an example for you to look at

    Thanks,
    mccreaso
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Mccreaso,

    The reasone the macro is returning a 1 is you are using the address of the Range (selection) and not the Range object itself. Here is the ammended code...

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    11-16-2006
    Posts
    80
    Quote Originally Posted by Leith Ross
    Hello Mccreaso,

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    thanks Leith,

    Works Great!
    mccreaso

  4. #4
    Registered User
    Join Date
    03-11-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: COUNTA Function in VBA

    Thank you for the great sharing.

    You can also select entire column A with this code
    Please Login or Register  to view this content.

+ 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