![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 7
|
I have:
------------------ Sub CountHowManyRowOfData() MsgBox ActiveSheet.UsedRange.rows.Count End Sub --------------------- to count how many rows have data. However, I've got formatted cells (with borders, etc) which are being counted in this too.... whilst i only wish to count how many rows from say the range B6 to I2000 are being used WITH DATA IN THEM. I don't want the formatted but technically empty cells in this count. Is there a way to do this? |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Leiden, The Netherlands
Posts: 68
|
You could use the CurrentRegion property if the rows you want to count are adjacent:
Activesheet.cells(5,5).CurrentRegion.Rows.Count should do the trick, supposing that the top left cell of your table is cell E5 Marc |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Posts: 7
|
I didn't realise that if a user using my spreadsheet were to use the Autofilter it would still count all the rows; is there anyway to only let it count the stuff that's SHOWING and the rows with data?
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Try;
Sub FilteredRow_Count() Dim Area As Range Dim Rowcount As Double Rowcount = -1 '// [A1] is the start of your Filterer row For Each Area In [A1].CurrentRegion.SpecialCells(xlVisible).Areas Rowcount = Rowcount + Area.Rows.Count Next MsgBox Rowcount End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|