[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Counting populated rows in an Excel Document

Posted on 2010-04-09
1
Medium Priority
?
349 Views
Last Modified: 2013-11-25
I have an excel 2003 document "Account_Type" that has a worksheet named "Data".  This sheet has headers on row 1.  What I need is to count the number of rows that have a value in column A.  If there are no rows with a value except for the header row, return 0.  Can someone help with some script that will do this using vbscript 6.0.
0
Comment
Question by:OB1Canobie
1 Comment
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 30222356
Something like this should work...


Dim xlApp, xlWb, xlWs

Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Open("c:\folder\subfolder\foo.xls")
Set xlWs = xlWb.Worksheets(1)

MsgBox "Populated rows: " & (xlApp.CountA(xlWs.Range("a:a")) - 1)

xlWb.Close False
Set xlWs = Nothing
Set xlWb = Nothing
xlApp.Quit
Set xlApp = Nothing

Open in new window

0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question