Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default AutoFilter Row Count

Hi,

I am new to VBA and would like to know if there is a way to count the
number of rows based on the autofilter criteria?

sample code below
Columns("A:D").Select
Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:="310"
Selection.AutoFilter Field:=4, Criteria1:="0", Operator:=xlAnd

on my data, this displays 4 rows. I need to know the number of rows
so that I can create another procedure that loops through the result
set of the auto-filter.

i hope i make sense

thank you all in advance

Cris

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default AutoFilter Row Count

Dim rng As Range

'get the number of rows in data
Set rng = Range(Range("A1"), Range("A1").End(xlDown))
'extend range to column D
With rng.Resize(, 4)
.AutoFilter
.AutoFilter Field:=3, Criteria1:="310"
.AutoFilter Field:=4, Criteria1:="0", Operator:=xlAnd
MsgBox "Num rows = " & rng.SpecialCells(xlCellTypeVisible).Count
End With

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message
ups.com...
Hi,

I am new to VBA and would like to know if there is a way to count the
number of rows based on the autofilter criteria?

sample code below
Columns("A:D").Select
Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:="310"
Selection.AutoFilter Field:=4, Criteria1:="0", Operator:=xlAnd

on my data, this displays 4 rows. I need to know the number of rows
so that I can create another procedure that loops through the result
set of the auto-filter.

i hope i make sense

thank you all in advance

Cris



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default AutoFilter Row Count

On Aug 2, 5:41 pm, "Bob Phillips" wrote:
Dim rng As Range

'get the number of rows in data
Set rng = Range(Range("A1"), Range("A1").End(xlDown))
'extend range to column D
With rng.Resize(, 4)
.AutoFilter
.AutoFilter Field:=3, Criteria1:="310"
.AutoFilter Field:=4, Criteria1:="0", Operator:=xlAnd
MsgBox "Num rows = " & rng.SpecialCells(xlCellTypeVisible).Count
End With

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message

ups.com...

Hi,


I am new to VBA and would like to know if there is a way to count the
number of rows based on the autofilter criteria?


sample code below
Columns("A:D").Select
Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:="310"
Selection.AutoFilter Field:=4, Criteria1:="0", Operator:=xlAnd


on my data, this displays 4 rows. I need to know the number of rows
so that I can create another procedure that loops through the result
set of the auto-filter.


i hope i make sense


thank you all in advance


Cris


Hi Bob,

Thanks for that. Although I have to do a count - 1 otherwise, it
includes my column headings. But other than that, works perfect.

Cris

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default AutoFilter Row Count

On Aug 3, 12:11 am, wrote:
On Aug 2, 5:41 pm, "Bob Phillips" wrote:





Dim rng As Range


'get the number of rows in data
Set rng = Range(Range("A1"), Range("A1").End(xlDown))
'extend range to column D
With rng.Resize(, 4)
.AutoFilter
.AutoFilter Field:=3, Criteria1:="310"
.AutoFilter Field:=4, Criteria1:="0", Operator:=xlAnd
MsgBox "Num rows = " & rng.SpecialCells(xlCellTypeVisible).Count
End With


--
HTH


Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)


wrote in message


oups.com...


Hi,


I am new to VBA and would like to know if there is a way to count the
number of rows based on the autofilter criteria?


sample code below
Columns("A:D").Select
Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:="310"
Selection.AutoFilter Field:=4, Criteria1:="0", Operator:=xlAnd


on my data, this displays 4 rows. I need to know the number of rows
so that I can create another procedure that loops through the result
set of the auto-filter.


i hope i make sense


thank you all in advance


Cris


Hi Bob,

Thanks for that. Although I have to do a count - 1 otherwise, it
includes my column headings. But other than that, works perfect.

Cris- Hide quoted text -

- Show quoted text -


Hi Bob,

Maybe you can help me again, if its not too much. I am having problems
getting the value of the cells that are on the autofilter result. I
can get their address though but it still not giving me the value that
i want. and if i do a rng.specialcells(xlCellTypeVisible).value, it
only gives me the "A1" value and it doesn't loop.

any help is greatly appreciated

thank you

Cris

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default AutoFilter Row Count

Cris,

What exactly do you mean by the value of the cells, all of them?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message
ups.com...
On Aug 3, 12:11 am, wrote:

Hi Bob,

Maybe you can help me again, if its not too much. I am having problems
getting the value of the cells that are on the autofilter result. I
can get their address though but it still not giving me the value that
i want. and if i do a rng.specialcells(xlCellTypeVisible).value, it
only gives me the "A1" value and it doesn't loop.

any help is greatly appreciated

thank you

Cris



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoFilter and row count Bob Excel Discussion (Misc queries) 5 March 29th 07 12:40 AM
auto count from autofilter Marisa Excel Discussion (Misc queries) 1 November 8th 06 04:09 AM
Count Not Appearing when using AutoFilter? BBob Excel Worksheet Functions 3 July 14th 05 11:56 PM
Autofilter record count Debbie Thompson Excel Discussion (Misc queries) 1 February 11th 05 05:32 PM
autofilter range count pauluk[_14_] Excel Programming 3 March 5th 04 01:33 AM


All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"