[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

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
0
Svgmassive
Asked:
Svgmassive
  • 4
  • 2
  • 2
2 Solutions
 
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
 
SvgmassiveAuthor Commented:
can this be done using ADO?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now