Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default determine range size after auto filter?

I have a routine whereby I filter a range and then I want to select a
specific column down to the last row number, and then performa subtotal on it.

When I run the code I get 385 rows. My range Calculation shows 425, the
total number of rows on the sheet.

Any Ideas?
================================================== ==
xlApp.Selection.AutoFilter
xlApp.Selection.AutoFilter Field:=26, Criteria1:="False"
xlApp.Selection.AutoFilter Field:=27, Criteria1:="False"
xlApp.Selection.AutoFilter Field:=15, Criteria1:="<=" & Now()
xlApp.Selection.AutoFilter Field:=22, Criteria1:=0
z = xlApp.ActiveSheet.AutoFilter.Range.Row - 1 +
xlApp.ActiveSheet.AutoFilter.Range.Rows.Count
Set xlRng = xlApp.Range(xlApp.Cells(4, 12), xlApp.Cells(z, 12))
xlApp.Selection.AutoFilter
xlApp.Sheets("Top Sheet").Select
xlApp.Range("a27").Formula = "Tasks Not Started"
xlApp.Range("b27") = xlApp.WorksheetFunction.Subtotal(3, xlRng)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default determine range size after auto filter?

xlApp.Range("b27") = xlApp.WorksheetFunction.Subtotal(3, xlRng)

should show the number of visible rows (assuming all visible rows in that
column are not empty).

it is hard to interpret "I get 385 rows" and "My range calculation shows
425"
to understand what your complaint is.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
I have a routine whereby I filter a range and then I want to select a
specific column down to the last row number, and then performa subtotal on

it.

When I run the code I get 385 rows. My range Calculation shows 425, the
total number of rows on the sheet.

Any Ideas?
================================================== ==
xlApp.Selection.AutoFilter
xlApp.Selection.AutoFilter Field:=26, Criteria1:="False"
xlApp.Selection.AutoFilter Field:=27, Criteria1:="False"
xlApp.Selection.AutoFilter Field:=15, Criteria1:="<=" & Now()
xlApp.Selection.AutoFilter Field:=22, Criteria1:=0
z = xlApp.ActiveSheet.AutoFilter.Range.Row - 1 +
xlApp.ActiveSheet.AutoFilter.Range.Rows.Count
Set xlRng = xlApp.Range(xlApp.Cells(4, 12), xlApp.Cells(z, 12))
xlApp.Selection.AutoFilter
xlApp.Sheets("Top Sheet").Select
xlApp.Range("a27").Formula = "Tasks Not Started"
xlApp.Range("b27") = xlApp.WorksheetFunction.Subtotal(3, xlRng)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default determine range size after auto filter?

Tom My complaint is that I get a value for "Z" of 425, when in actual fact
the filtered range adds up to 385. So when I pass "Z" into a calculation to
select the last row I always get more rows than are actually filtered

"Tom Ogilvy" wrote:

xlApp.Range("b27") = xlApp.WorksheetFunction.Subtotal(3, xlRng)

should show the number of visible rows (assuming all visible rows in that
column are not empty).

it is hard to interpret "I get 385 rows" and "My range calculation shows
425"
to understand what your complaint is.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
I have a routine whereby I filter a range and then I want to select a
specific column down to the last row number, and then performa subtotal on

it.

When I run the code I get 385 rows. My range Calculation shows 425, the
total number of rows on the sheet.

Any Ideas?
================================================== ==
xlApp.Selection.AutoFilter
xlApp.Selection.AutoFilter Field:=26, Criteria1:="False"
xlApp.Selection.AutoFilter Field:=27, Criteria1:="False"
xlApp.Selection.AutoFilter Field:=15, Criteria1:="<=" & Now()
xlApp.Selection.AutoFilter Field:=22, Criteria1:=0
z = xlApp.ActiveSheet.AutoFilter.Range.Row - 1 +
xlApp.ActiveSheet.AutoFilter.Range.Rows.Count
Set xlRng = xlApp.Range(xlApp.Cells(4, 12), xlApp.Cells(z, 12))
xlApp.Selection.AutoFilter
xlApp.Sheets("Top Sheet").Select
xlApp.Range("a27").Formula = "Tasks Not Started"
xlApp.Range("b27") = xlApp.WorksheetFunction.Subtotal(3, xlRng)




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default determine range size after auto filter?

The code you show should return the row number of the last row in the
Autofilter range. I suspect the autofilter extends down to row 425.

--
Regards,
Tom Ogilvy

"jeff" wrote in message
...
Tom My complaint is that I get a value for "Z" of 425, when in actual fact
the filtered range adds up to 385. So when I pass "Z" into a calculation

to
select the last row I always get more rows than are actually filtered

"Tom Ogilvy" wrote:

xlApp.Range("b27") = xlApp.WorksheetFunction.Subtotal(3, xlRng)

should show the number of visible rows (assuming all visible rows in

that
column are not empty).

it is hard to interpret "I get 385 rows" and "My range calculation

shows
425"
to understand what your complaint is.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
I have a routine whereby I filter a range and then I want to select a
specific column down to the last row number, and then performa

subtotal on
it.

When I run the code I get 385 rows. My range Calculation shows 425,

the
total number of rows on the sheet.

Any Ideas?
================================================== ==
xlApp.Selection.AutoFilter
xlApp.Selection.AutoFilter Field:=26, Criteria1:="False"
xlApp.Selection.AutoFilter Field:=27, Criteria1:="False"
xlApp.Selection.AutoFilter Field:=15, Criteria1:="<=" & Now()
xlApp.Selection.AutoFilter Field:=22, Criteria1:=0
z = xlApp.ActiveSheet.AutoFilter.Range.Row - 1 +
xlApp.ActiveSheet.AutoFilter.Range.Rows.Count
Set xlRng = xlApp.Range(xlApp.Cells(4, 12), xlApp.Cells(z, 12))
xlApp.Selection.AutoFilter
xlApp.Sheets("Top Sheet").Select
xlApp.Range("a27").Formula = "Tasks Not Started"
xlApp.Range("b27") = xlApp.WorksheetFunction.Subtotal(3, xlRng)






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
Auto Filter - drop down (increase text size) Brandon.chamberlain Excel Discussion (Misc queries) 2 November 2nd 06 03:50 PM
size limitations on auto filter jeo1 Excel Discussion (Misc queries) 2 April 7th 06 02:43 PM
How a macro auto-determine unspecified range eric c Excel Programming 1 October 26th 04 07:49 PM
How to determine a range size cici Excel Programming 1 February 11th 04 10:16 PM
In VB, get Auto Filter Range Michael Kintner Excel Programming 1 November 24th 03 07:07 PM


All times are GMT +1. The time now is 11:53 PM.

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"