PC Review


Reply
Thread Tools Rate Thread

Count Visible Cells when using Filters

 
 
Canlink
Guest
Posts: n/a
 
      12th Jun 2008
I would like to count only the visible cells in order to set the
number of pages when using filters on a database.

Has anyone reasoned out the correct coding?
 
Reply With Quote
 
 
 
 
ryguy7272
Guest
Posts: n/a
 
      12th Jun 2008
Since you posted in the Excel Programming area, I think this may not really
be what you want, but you didn't give a whole lot of information, or
requirements, so this may actually work for you.
http://www.techonthenet.com/excel/formulas/subtotal.php

Regards,
Ryan--


--
RyGuy


"Canlink" wrote:

> I would like to count only the visible cells in order to set the
> number of pages when using filters on a database.
>
> Has anyone reasoned out the correct coding?
>

 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      12th Jun 2008
you can try something like this. in this example, my column headers are in row
5, columns A thru U on sheet1.

Option Explicit
Sub test()
Dim ws As Worksheet
Dim lastrow As Long
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
Dim filtlastrow As Long
With ws.Range("A5:U" & lastrow)
.AutoFilter field:=1, Criteria1:="01"
filtlastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
If .Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count = 1 Then
'nothing but headers are visible
Else
MsgBox ws.Range("A6:A" & _
filtlastrow).SpecialCells(xlCellTypeVisible).Count
End If
End With
End Sub

--


Gary


"Canlink" <(E-Mail Removed)> wrote in message
news:e5283797-10e0-441b-9754-(E-Mail Removed)...
>I would like to count only the visible cells in order to set the
> number of pages when using filters on a database.
>
> Has anyone reasoned out the correct coding?



 
Reply With Quote
 
Canlink
Guest
Posts: n/a
 
      13th Jun 2008
On Jun 12, 12:00 am, "Gary Keramidas" <GKeramidasATmsn.com> wrote:
> you can try something like this. in this example, my column headers are in row
> 5, columns A thru U on sheet1.
>
> Option Explicit
> Sub test()
> Dim ws As Worksheet
> Dim lastrow As Long
> Set ws = Worksheets("Sheet1")
> lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
> Dim filtlastrow As Long
> With ws.Range("A5:U" & lastrow)
> .AutoFilter field:=1, Criteria1:="01"
> filtlastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
> If .Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count= 1 Then
> 'nothing but headers arevisible
> Else
> MsgBox ws.Range("A6:A" & _
> filtlastrow).SpecialCells(xlCellTypeVisible).Count
> End If
> End With
> End Sub
>
> --
>
> Gary
>
> "Canlink" <canl...@gmail.com> wrote in message
>
> news:e5283797-10e0-441b-9754-(E-Mail Removed)...
>
> >I would like tocountonly thevisiblecellsin order to set the
> > number of pages whenusingfilterson a database.

>
> > Has anyone reasoned out the correct coding?


Gary:
The coding is almost what I am looking for and I think I can modify
your suggestion to count the visible rows in a filtered database so I
can set the number of pages that will be printing showing this
selection.
Thanks
Geoff
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum of visible cells with multiple filters - Office 2007 Bruce Microsoft Excel Worksheet Functions 2 4th Jul 2008 03:11 AM
Count Only Visible Cells =?Utf-8?B?Y2FybA==?= Microsoft Excel Worksheet Functions 1 23rd Sep 2004 02:00 PM
SUBTOTAL Second Count / sub-count of Filtered Visible Cells QTE Microsoft Excel Misc 13 4th Aug 2004 04:47 PM
SUBTOTAL Second Count / sub-count of Filtered Visible Cells QTE Microsoft Excel Worksheet Functions 0 27th Jul 2004 08:47 PM
SUBTOTAL Second Count / sub-count of Filtered Visible Cells QTE Microsoft Excel Worksheet Functions 3 21st Jul 2004 11:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:38 PM.