Count the number of used row in a closed workbook

I would like to count the number of used rows in an named range in a closed workbook.
thanks
SvgmassiveAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Hello,

Construct the formula with both files open, then close the file. That is easier than trying to create a formula from scratch referencing a closed workbook.

Open both files. In the target file create the formula to count the rows in the range of the source file. Close the source file.  Look at the formula. If you use the Counta() function, it will look similar to this:

=COUNTA('C:\Users\path\closedFile.xlsx'!Myrange)

Does that help?

cheers, teylyn
0
Glenn RayExcel VBA DeveloperCommented:
To get the number of rows:
=ROWS('C:\filepath\filename.xlsx'!rangename)

Make sure you use the correct file extension (.xls, .xlsx, .xlsm) above and that you enclose the full filepath and filename with apostrophes ( ' ).

Regards,
-Glenn
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SvgmassiveAuthor Commented:
can this be done using ADO?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Maybe it would be a good idea to tell us exactly what you want instead of drip-feeding us information. It would take a lot of guesswork out of the answers and save valuable time.
0
Glenn RayExcel VBA DeveloperCommented:
I agree with teylyn.  Frankly, I don't understand your follow-up question at all; I see no correlation between ADO and this requirement.  Are you trying to estimate the number of records to import from an external spreadsheet?

-Glenn
0
SvgmassiveAuthor Commented:
yes glen ray..correct
0
Glenn RayExcel VBA DeveloperCommented:
Well, you don't need ADO to do it; just create the ROWS formula above and reference the data range in the workbook.  It should work and run faster than opening an ADODB connection, executing a query, doing a MoveLast command and trying to estimate the record count from that.
0
Glenn RayExcel VBA DeveloperCommented:
In fact, some database systems don't recognize RecordCount; see this thread:
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28495027.html
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.