Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Return filtered tasks

I'm having a problem getting the correct number of rows returned to me after
filtering.


I have the following lines in my Init Function.

ActiveSheet.AutoFilterMode = False
Range("A1", Cells(Rows.Count, 1).End(xlUp)).Resize(, 13).Select
total_nachos = Selection.Rows.Count

this returns the proper value to total_nachos, which is how many rows are in
my entire excel sheet a little over 20,000.

I dynamically build my filter list off column I (9) and need to store the
number of filtered tasks found when applying the filter. Here are the lines
I'm using when I apply the filter.

Selection.AutoFilter Field:=MyCategoryCol, Criteria1:=CatBuffer(2)
This applies the filter I want, and I see in the lower left the accurate
number of tasks. However, I cannot seem to get an accurate count returned to
the code - which is what I need, I get numbers that are way out of wack when
I populate my value.

Range("I1", Cells(Rows.Count, 1).End(xlUp)).Resize(, 13).Select
value=Select.Rows.Count

I'm sure it's something simple, I'm more of a VBA MS Project guy and this is
my first excel macro which has been a booming success with all my Project
knowledge, but the functions for returning ActiveSelections of rows/tasks are
different.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Return filtered tasks

Hi Finius

See
http://www.contextures.com/xlautofilter02.html#Count

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Finius Eetch" wrote in message ...
I'm having a problem getting the correct number of rows returned to me after
filtering.


I have the following lines in my Init Function.

ActiveSheet.AutoFilterMode = False
Range("A1", Cells(Rows.Count, 1).End(xlUp)).Resize(, 13).Select
total_nachos = Selection.Rows.Count

this returns the proper value to total_nachos, which is how many rows are in
my entire excel sheet a little over 20,000.

I dynamically build my filter list off column I (9) and need to store the
number of filtered tasks found when applying the filter. Here are the lines
I'm using when I apply the filter.

Selection.AutoFilter Field:=MyCategoryCol, Criteria1:=CatBuffer(2)
This applies the filter I want, and I see in the lower left the accurate
number of tasks. However, I cannot seem to get an accurate count returned to
the code - which is what I need, I get numbers that are way out of wack when
I populate my value.

Range("I1", Cells(Rows.Count, 1).End(xlUp)).Resize(, 13).Select
value=Select.Rows.Count

I'm sure it's something simple, I'm more of a VBA MS Project guy and this is
my first excel macro which has been a booming success with all my Project
knowledge, but the functions for returning ActiveSelections of rows/tasks are
different.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Return filtered tasks

Ron,
What i'm looking for is the ability to hold the 'number of records
found' in a VBA variable. This variable is passed into various VBA functions
that crunches all my data. Is there a way to extract that information that I
haven't found? Something along the lines of.

dim total_records_found as long
total_records_found =FilteredTaskRecords

I've tried Selection.Rows.Count, but the numbers it gives me are wrong.
I'm not very familiar with the Range command so perhaps that is why my info
from Selection.Rows.Count is wrong. I need to count the number of records in
the I column, or Column 9 after I've applied a filter to Column I/9. I do
not want to count each cell in a loop if possible. Obviously excel has the
answer for me when I sort 23,000 rows of categories for 'Kids' and it returns
213 entries. However, I get back on the order of 14,000 and change. The
ONLY time I get the right data is before any filters are applied and I get
the total number of rows.

Any help would be greatly appreciated. Once I get this knocked out I can go
back to my MSProject hole :)
'F.E.

"Ron de Bruin" wrote:

Hi Finius

See
http://www.contextures.com/xlautofilter02.html#Count

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Finius Eetch" wrote in message ...
I'm having a problem getting the correct number of rows returned to me after
filtering.


I have the following lines in my Init Function.

ActiveSheet.AutoFilterMode = False
Range("A1", Cells(Rows.Count, 1).End(xlUp)).Resize(, 13).Select
total_nachos = Selection.Rows.Count

this returns the proper value to total_nachos, which is how many rows are in
my entire excel sheet a little over 20,000.

I dynamically build my filter list off column I (9) and need to store the
number of filtered tasks found when applying the filter. Here are the lines
I'm using when I apply the filter.

Selection.AutoFilter Field:=MyCategoryCol, Criteria1:=CatBuffer(2)
This applies the filter I want, and I see in the lower left the accurate
number of tasks. However, I cannot seem to get an accurate count returned to
the code - which is what I need, I get numbers that are way out of wack when
I populate my value.

Range("I1", Cells(Rows.Count, 1).End(xlUp)).Resize(, 13).Select
value=Select.Rows.Count

I'm sure it's something simple, I'm more of a VBA MS Project guy and this is
my first excel macro which has been a booming success with all my Project
knowledge, but the functions for returning ActiveSelections of rows/tasks are
different.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Return filtered tasks

You can use this with code

total_records_found = application.WorksheetFunction.Subtotal(........... ...........)


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Finius Eetch" wrote in message ...
Ron,
What i'm looking for is the ability to hold the 'number of records
found' in a VBA variable. This variable is passed into various VBA functions
that crunches all my data. Is there a way to extract that information that I
haven't found? Something along the lines of.

dim total_records_found as long
total_records_found =FilteredTaskRecords

I've tried Selection.Rows.Count, but the numbers it gives me are wrong.
I'm not very familiar with the Range command so perhaps that is why my info
from Selection.Rows.Count is wrong. I need to count the number of records in
the I column, or Column 9 after I've applied a filter to Column I/9. I do
not want to count each cell in a loop if possible. Obviously excel has the
answer for me when I sort 23,000 rows of categories for 'Kids' and it returns
213 entries. However, I get back on the order of 14,000 and change. The
ONLY time I get the right data is before any filters are applied and I get
the total number of rows.

Any help would be greatly appreciated. Once I get this knocked out I can go
back to my MSProject hole :)
'F.E.

"Ron de Bruin" wrote:

Hi Finius

See
http://www.contextures.com/xlautofilter02.html#Count

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Finius Eetch" wrote in message
...
I'm having a problem getting the correct number of rows returned to me after
filtering.


I have the following lines in my Init Function.

ActiveSheet.AutoFilterMode = False
Range("A1", Cells(Rows.Count, 1).End(xlUp)).Resize(, 13).Select
total_nachos = Selection.Rows.Count

this returns the proper value to total_nachos, which is how many rows are in
my entire excel sheet a little over 20,000.

I dynamically build my filter list off column I (9) and need to store the
number of filtered tasks found when applying the filter. Here are the lines
I'm using when I apply the filter.

Selection.AutoFilter Field:=MyCategoryCol, Criteria1:=CatBuffer(2)
This applies the filter I want, and I see in the lower left the accurate
number of tasks. However, I cannot seem to get an accurate count returned to
the code - which is what I need, I get numbers that are way out of wack when
I populate my value.

Range("I1", Cells(Rows.Count, 1).End(xlUp)).Resize(, 13).Select
value=Select.Rows.Count

I'm sure it's something simple, I'm more of a VBA MS Project guy and this is
my first excel macro which has been a booming success with all my Project
knowledge, but the functions for returning ActiveSelections of rows/tasks are
different.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Return filtered tasks

Ron,
Thanks, that gave me exactly what I needed to extract the number of
records.

"Ron de Bruin" wrote:

You can use this with code

total_records_found = application.WorksheetFunction.Subtotal(........... ...........)


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Finius Eetch" wrote in message ...
Ron,
What i'm looking for is the ability to hold the 'number of records
found' in a VBA variable. This variable is passed into various VBA functions
that crunches all my data. Is there a way to extract that information that I
haven't found? Something along the lines of.

dim total_records_found as long
total_records_found =FilteredTaskRecords

I've tried Selection.Rows.Count, but the numbers it gives me are wrong.
I'm not very familiar with the Range command so perhaps that is why my info
from Selection.Rows.Count is wrong. I need to count the number of records in
the I column, or Column 9 after I've applied a filter to Column I/9. I do
not want to count each cell in a loop if possible. Obviously excel has the
answer for me when I sort 23,000 rows of categories for 'Kids' and it returns
213 entries. However, I get back on the order of 14,000 and change. The
ONLY time I get the right data is before any filters are applied and I get
the total number of rows.

Any help would be greatly appreciated. Once I get this knocked out I can go
back to my MSProject hole :)
'F.E.

"Ron de Bruin" wrote:

Hi Finius

See
http://www.contextures.com/xlautofilter02.html#Count

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Finius Eetch" wrote in message
...
I'm having a problem getting the correct number of rows returned to me after
filtering.


I have the following lines in my Init Function.

ActiveSheet.AutoFilterMode = False
Range("A1", Cells(Rows.Count, 1).End(xlUp)).Resize(, 13).Select
total_nachos = Selection.Rows.Count

this returns the proper value to total_nachos, which is how many rows are in
my entire excel sheet a little over 20,000.

I dynamically build my filter list off column I (9) and need to store the
number of filtered tasks found when applying the filter. Here are the lines
I'm using when I apply the filter.

Selection.AutoFilter Field:=MyCategoryCol, Criteria1:=CatBuffer(2)
This applies the filter I want, and I see in the lower left the accurate
number of tasks. However, I cannot seem to get an accurate count returned to
the code - which is what I need, I get numbers that are way out of wack when
I populate my value.

Range("I1", Cells(Rows.Count, 1).End(xlUp)).Resize(, 13).Select
value=Select.Rows.Count

I'm sure it's something simple, I'm more of a VBA MS Project guy and this is
my first excel macro which has been a booming success with all my Project
knowledge, but the functions for returning ActiveSelections of rows/tasks are
different.






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
Return the filtered value into a specific cell Sal Excel Worksheet Functions 5 April 5th 23 01:23 PM
Return filtered values into report worksheet based on filtered valueon the data worksheet dicko1 Excel Worksheet Functions 1 April 21st 09 12:27 AM
Filtered cells return after saving Susienak Excel Discussion (Misc queries) 4 November 18th 07 01:40 PM
Return Value from a Filtered List [email protected] Excel Worksheet Functions 4 August 7th 07 06:10 PM
return row count of filtered data. tarns[_6_] Excel Programming 2 March 10th 06 08:03 AM


All times are GMT +1. The time now is 02:25 PM.

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

About Us

"It's about Microsoft Excel"