I'm thinking there's got to be an easy way to get Excel VBA to return the count of occupied cells in a specified column. I tried HdrCnt = Columns("A:A").Count but that just returns 1 regardless of what is in the column. Thanks.
or Hi-light the column e.g.click on the column header A
then on the bottom line of your spreadsheet (where it says Ready in the lower left) Right click and choose any of the following: none, avg, count, count numbers, max, min or sum and your results appear on that bottom line.
I'm doing this in VBA because I want to know if the user has loaded data on which to run the program. If data has not been loaded, I give the user a message to load data. I've figured it out though:
With Workbooks(ThisWkBk).Worksheets(HdrWks)
RowCount = Columns("A:A").Rows.Count
End With
LastRow = "A" & RowCount
HeaderCnt = .Range("A1", .Range(LastRow).End(xlUp)).Rows.Count
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.