#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default AutoFilter

I am having trouble getting AutoFilter to work using VB code. The problem is
that the Criteria sometimes changes depending upon the format of the data.
For example using the data below, the code:
Selection.AutoFilter Field:=2, Criteria1:="-49276.80078"
sometimes filters the data. But if the number format is #.00 then the code:
Selection.AutoFilter Field:=2, Criteria1:="-49276.80" is required.
This is further complicated by the fact that the code:
Selection.AutoFilter Field:=2, Criteria1:="-50000"
is required reguardless of Number format. That is
Selection.AutoFilter Field:=2, Criteria1:="-50000.0"
WILL NOT WORK.

Col A Col B
1 -50000
2 -49276.80078
3 -48476.80078
4 -47676.80078
5 -46876.80078

Is this a bug?

Tx,

Randall



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default AutoFilter

Hi
You may need to format numbers in column to what is in your macro or use
something like
For Each CELL In Range("B:B")
MYV = CELL
Selection.AutoFilter Field:=2, Criteria1:=MYV
Next CELL
so criteria to select is always whats on your sheet in correct format

Tina
"Randall" wrote:

I am having trouble getting AutoFilter to work using VB code. The problem is
that the Criteria sometimes changes depending upon the format of the data.
For example using the data below, the code:
Selection.AutoFilter Field:=2, Criteria1:="-49276.80078"
sometimes filters the data. But if the number format is #.00 then the code:
Selection.AutoFilter Field:=2, Criteria1:="-49276.80" is required.
This is further complicated by the fact that the code:
Selection.AutoFilter Field:=2, Criteria1:="-50000"
is required reguardless of Number format. That is
Selection.AutoFilter Field:=2, Criteria1:="-50000.0"
WILL NOT WORK.

Col A Col B
1 -50000
2 -49276.80078
3 -48476.80078
4 -47676.80078
5 -46876.80078

Is this a bug?

Tx,

Randall



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
excel 2007 autofilter change to 2003 autofilter functionality? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 10:05 PM
2007 excel autofilter back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 3 April 19th 10 08:11 PM
2007 excel autofilter change back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 05:53 PM
2007 Autofilter worse than 2003 Autofilter jsky Excel Discussion (Misc queries) 9 October 31st 07 12:14 AM
How to Sort within AutoFilter with Protection on (and AutoFilter . giblon Excel Discussion (Misc queries) 1 February 16th 06 12:23 PM


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