By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,037 Members | 1,839 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,037 IT Pros & Developers. It's quick & easy.

How to return a record count?

P: 1
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.
May 2 '10 #1
Share this Question
Share on Google+
2 Replies


Jim Doherty
Expert 100+
P: 897
@regent77
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 :)
May 4 '10 #2

NeoPa
Expert Mod 15k+
P: 31,494
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, WorksheetFunction(), that allows you to use this function in your VBA.

Welcome to Bytes!
May 4 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.