View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default How to get number of filtered records found displayed in a cel

Hi joel,

That code only counts the rows until it comes to the first hidden row. Note
that it includes the column header but nothing from the first non visible
row down. I realize that one would expect it to work but for some reason it
does not.

I have previously tried the following method and it has the same problem.

countVisibleRows = Sheets("Sheet1").AutoFilter.Range. _
SpecialCells(xlCellTypeVisible).Rows.Count

The total cells can be counted with the following. Note that the count
includes the column header cells as would the above code if it worked:-

countVisibleCells = Sheets("Sheet1").AutoFilter.Range. _
SpecialCells(xlCellTypeVisible).Cells.Count

columns count also works with the above code.

One of life's mysteries I suppose.

--
Regards,

OssieMac


"joel" wrote:

Does this help

Lastrow = Range("A" & Rows.Count).End(xlUp).Row
Set DataRange = Range("A1:A" & Lastrow)
VisibleRows = DataRange.Cells.SpecialCells(xlCellTypeVisible).Ro ws.Count

"Jessica New Forest" wrote:

Having created several macros to run filters in my spreadsheet on the click
of a button for each category, I now want the number of records found with
each macro to be displayed in a table on the same worksheet, for an end of
month report. i'm sure there's a simple way to do it!