View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
DGillham[_5_] DGillham[_5_] is offline
external usenet poster
 
Posts: 1
Default Macro for counting the number of filtered rows


Hi

I am using an autofilter on my data and need to be able to add a total
at the bottom of that filter that tells me how many rows are included
in the filter. Microsoft kindly provides the following code:

Dim UpperLeftCorner As Range

' UpperLeftCorner should be set to the upper-left
' corner of the list range:
Set UpperLeftCorner = Sheets("Sheet1").Range("A4")

RowCount = -1
For Each area In _
UpperLeftCorner.CurrentRegion.SpecialCells(xlVisib le).Areas
RowCount = RowCount + area.Rows.Count
Next
MsgBox RowCount

This works fine, by rather than a message box I would like to actually
add this total to the worksheet - any ideas how this can be done?

Thanks

Darren


--
DGillham
------------------------------------------------------------------------
DGillham's Profile: http://www.excelforum.com/member.php...o&userid=13707
View this thread: http://www.excelforum.com/showthread...hreadid=499343