Forum Discussion
ClaireMcF
Mar 02, 2023Brass Contributor
Loop Through Worksheets and Counts Populated Rows
I want to create a macro that I can run each week. I have a workbook and on the first worksheet I want to count how many populated rows there are on the other worksheets. So in this example I want a...
ClaireMcF
Mar 06, 2023Brass Contributor
Hi rzaneti
Thanks for your reply - this is really helpful. I have tried to run the code on my workbook, but I am getting a debug error at the :
CurrentSheetCount = ActiveCell.Row - 1 'Store the row number and subtract 1, as we have to discount the "A1" cell
and the code does not execute.
Can you help at all please?
Thanks
Claire
Thanks for your reply - this is really helpful. I have tried to run the code on my workbook, but I am getting a debug error at the :
CurrentSheetCount = ActiveCell.Row - 1 'Store the row number and subtract 1, as we have to discount the "A1" cell
and the code does not execute.
Can you help at all please?
Thanks
Claire
rzaneti
Mar 06, 2023Iron Contributor
Hi, ClaireMcF .
There are some possible reasons for an error at this line of code. Could you please send an image of the error message?
One of the possible problems is the error 6 (overflow), which will happen if we have an empty Sheet or if you have a specific Sheet with a large number of rows (more than 32,767 rows). Can you confirm if you have any of these cases in your file?
- ClaireMcFMar 08, 2023Brass ContributorHi, sorry for delayed response. I am still looking at this as I can't get your macro to run properly. Need to spend some time just having a run through it. Thanks
- ClaireMcFMar 06, 2023Brass ContributorThanks so much - I don't have an empty sheet but when I ran the code for the first time it jumps to the 'Mohan' worksheet and settles on row 1048576 and I get the 6 (overflow) error that you mention below. So I deleted the empty rows from row 3 to row 1048576 and ran the code again. Same thing happens, and the cursor settles on Mohan, row 1048576. Thankyou