How to return a record count?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • regent77
    New Member
    • May 2010
    • 1

    #1

    How to return a record count?

    hello All,

    I am new to VBA programming. I have an Excel sheet with a list of records. For instance, Last name and city. I would like to write a macro to select the desired city and return a count in Excel. For instance, user selects Denver, and the program will return 15.

    Thank you very much.
  • Jim Doherty
    Recognized Expert Contributor
    • Aug 2007
    • 897

    #2
    Originally posted by regent77
    hello All,

    I am new to VBA programming. I have an Excel sheet with a list of records. For instance, Last name and city. I would like to write a macro to select the desired city and return a count. For instance, user selects Denver, and the program will return 15.

    Thank you very much.
    Can you not just attach the sheet as a linked table in Access? then you can query that table as any other table in Access.......if that is,you are working IN Access, as opposed to excel

    Welcome to Bytes :)

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      I'm assuming this is actually in Excel, though it would be a good idea to say so in your question if so, considering this is an Access / VBA forum.

      Firstly, you can include COUNTIF() in a formula, to count the rows that match your criteria. If you want to do this in VBA, then there is also a method, WorksheetFuncti on(), that allows you to use this function in your VBA.

      Welcome to Bytes!

      Comment

      Working...