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

Hello,

I have a table with a column called "Source". This column can take on any
one of 50 values. I would like to use autofilter to filter out about 30 of
them. Is it possible with autofilter & VBA?

I am thinking about using VBA to concatinate the 20 admissible source names
into one long string (strLong), then use it in an autofilter criterion on
the Source field. More specifically, I hope to find a criterion specifying
that the field value is to be part of strLong. Unfortunately, criterion such
as :="*<string*" works the other way round (ie it requires the field to
contain a certain string). So I got stuck.

Suggestions are most welcome! (I use Excel XP).


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Autofilter Macro

One way is to use a helper column. Place strLong in a cell (in my example
G2), place formula
=ISNUMBER(SEARCH(F2,$G$2))
in first cell of the helper column (in my example F2), fill it down as
required, and Autofilter column F for TRUE.
Regards,
Stefi


robot ezt *rta:

Hello,

I have a table with a column called "Source". This column can take on any
one of 50 values. I would like to use autofilter to filter out about 30 of
them. Is it possible with autofilter & VBA?

I am thinking about using VBA to concatinate the 20 admissible source names
into one long string (strLong), then use it in an autofilter criterion on
the Source field. More specifically, I hope to find a criterion specifying
that the field value is to be part of strLong. Unfortunately, criterion such
as :="*<string*" works the other way round (ie it requires the field to
contain a certain string). So I got stuck.

Suggestions are most welcome! (I use Excel XP).



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Autofilter Macro

Dear Stefi,

I'll try that. Thanks for your reply.

"Stefi" ...
One way is to use a helper column. Place strLong in a cell (in my example
G2), place formula
=ISNUMBER(SEARCH(F2,$G$2))
in first cell of the helper column (in my example F2), fill it down as
required, and Autofilter column F for TRUE.
Regards,
Stefi


?robot ezt irta:

Hello,

I have a table with a column called "Source". This column can take on any
one of 50 values. I would like to use autofilter to filter out about 30
of
them. Is it possible with autofilter & VBA?

I am thinking about using VBA to concatinate the 20 admissible source
names
into one long string (strLong), then use it in an autofilter criterion on
the Source field. More specifically, I hope to find a criterion
specifying
that the field value is to be part of strLong. Unfortunately, criterion
such
as :="*<string*" works the other way round (ie it requires the field to
contain a certain string). So I got stuck.

Suggestions are most welcome! (I use Excel XP).





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Autofilter Macro

It is probably better to use Advance Filter which has an option to have a
criteria range of multiple items. Try using Advance filtering from the
worksheet menu to seee how it works. another choice is to create you own
filtering using arrays

MyArray = Array("Item 1", "Item 2", "Item 3", "Item 4")

for each itm in MyArray

'add your code here
next itm

"robot" wrote:

Hello,

I have a table with a column called "Source". This column can take on any
one of 50 values. I would like to use autofilter to filter out about 30 of
them. Is it possible with autofilter & VBA?

I am thinking about using VBA to concatinate the 20 admissible source names
into one long string (strLong), then use it in an autofilter criterion on
the Source field. More specifically, I hope to find a criterion specifying
that the field value is to be part of strLong. Unfortunately, criterion such
as :="*<string*" works the other way round (ie it requires the field to
contain a certain string). So I got stuck.

Suggestions are most welcome! (I use Excel XP).



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Autofilter Macro

Thank you for your reply.

Actually I have used autofilter on other columns, so I think I'll stick to
autofilter in the mean time.

Filtering by array? How do I go about doing that? Grateful if you would
provide more details. Thanks again.

"Joel" ...
It is probably better to use Advance Filter which has an option to have a
criteria range of multiple items. Try using Advance filtering from the
worksheet menu to seee how it works. another choice is to create you own
filtering using arrays

MyArray = Array("Item 1", "Item 2", "Item 3", "Item 4")

for each itm in MyArray

'add your code here
next itm

"robot" wrote:

Hello,

I have a table with a column called "Source". This column can take on any
one of 50 values. I would like to use autofilter to filter out about 30
of
them. Is it possible with autofilter & VBA?

I am thinking about using VBA to concatinate the 20 admissible source
names
into one long string (strLong), then use it in an autofilter criterion on
the Source field. More specifically, I hope to find a criterion
specifying
that the field value is to be part of strLong. Unfortunately, criterion
such
as :="*<string*" works the other way round (ie it requires the field to
contain a certain string). So I got stuck.

Suggestions are most welcome! (I use Excel XP).







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Autofilter Macro

If you arre going to use Stefi's suggestion of creating a helper column then
the helper column becomes the criteria for the Advance filter. After you
generate the helper column try manually on the worksheet and use the Advance
Filter. If you lkike the results then simply record a macro while performing
the Advance filter and then copy the recorded code into your macro.

"robot" wrote:

Thank you for your reply.

Actually I have used autofilter on other columns, so I think I'll stick to
autofilter in the mean time.

Filtering by array? How do I go about doing that? Grateful if you would
provide more details. Thanks again.

"Joel" ...
It is probably better to use Advance Filter which has an option to have a
criteria range of multiple items. Try using Advance filtering from the
worksheet menu to seee how it works. another choice is to create you own
filtering using arrays

MyArray = Array("Item 1", "Item 2", "Item 3", "Item 4")

for each itm in MyArray

'add your code here
next itm

"robot" wrote:

Hello,

I have a table with a column called "Source". This column can take on any
one of 50 values. I would like to use autofilter to filter out about 30
of
them. Is it possible with autofilter & VBA?

I am thinking about using VBA to concatinate the 20 admissible source
names
into one long string (strLong), then use it in an autofilter criterion on
the Source field. More specifically, I hope to find a criterion
specifying
that the field value is to be part of strLong. Unfortunately, criterion
such
as :="*<string*" works the other way round (ie it requires the field to
contain a certain string). So I got stuck.

Suggestions are most welcome! (I use Excel XP).






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 macro SteveDB1 Excel Programming 1 March 11th 09 04:36 PM
Macro using autofilter Lorna B Excel Discussion (Misc queries) 5 May 25th 07 06:54 PM
autofilter macro flow23 Excel Discussion (Misc queries) 1 April 18th 06 03:00 PM
Autofilter macro Jessica Excel Programming 1 December 1st 05 10:54 PM
Keep autofilter after macro is run gmr7 Excel Worksheet Functions 2 July 5th 05 01:16 PM


All times are GMT +1. The time now is 04:18 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"