PC Review


Reply
Thread Tools Rate Thread

Autofilter - formatting criteria1 data for valid comparison

 
 
Dennis
Guest
Posts: n/a
 
      4th Dec 2006
2003

Procedure obtains a numeric value (NumbToReplace) from an input box.

The typical worksheet column format is:
NumberFormat = "#,##0.00_);(#,##0.00)" 'Number with 2 Dec Places

But the same column on other worksheets have format of:
NumberFormat = "#,##0.00000_);(#,##0.00000)" 'Number with 5

I format NumbToReplace as follows:
FilterCriteria = WorksheetFunction.Text(NumbToReplace, _
"#,##0.00_);(#,##0.00)")

Then I set the filter:
Filter1.AutoFilter Field:=4, Criteria1:="=" & FilterCriteria

The challenge: How to format "NumbToReplace" which becomes
"FilterCriteria" so that the filter is set properly no matter how many
decimal places the worksheet column has?

I am having a can't-see-the-forest-for-the-trees-moment even though the
answer is probably staring me right in the face..

TIA EagleOne

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      4th Dec 2006
Can you pick up the numberformat from one of the cells in that column?

Dennis wrote:
>
> 2003
>
> Procedure obtains a numeric value (NumbToReplace) from an input box.
>
> The typical worksheet column format is:
> NumberFormat = "#,##0.00_);(#,##0.00)" 'Number with 2 Dec Places
>
> But the same column on other worksheets have format of:
> NumberFormat = "#,##0.00000_);(#,##0.00000)" 'Number with 5
>
> I format NumbToReplace as follows:
> FilterCriteria = WorksheetFunction.Text(NumbToReplace, _
> "#,##0.00_);(#,##0.00)")
>
> Then I set the filter:
> Filter1.AutoFilter Field:=4, Criteria1:="=" & FilterCriteria
>
> The challenge: How to format "NumbToReplace" which becomes
> "FilterCriteria" so that the filter is set properly no matter how many
> decimal places the worksheet column has?
>
> I am having a can't-see-the-forest-for-the-trees-moment even though the
> answer is probably staring me right in the face..
>
> TIA EagleOne


--

Dave Peterson
 
Reply With Quote
 
Dennis
Guest
Posts: n/a
 
      4th Dec 2006
DA!

Thanks Dave

Dave Peterson wrote:
> Can you pick up the numberformat from one of the cells in that column?
>
> Dennis wrote:
> >
> > 2003
> >
> > Procedure obtains a numeric value (NumbToReplace) from an input box.
> >
> > The typical worksheet column format is:
> > NumberFormat = "#,##0.00_);(#,##0.00)" 'Number with 2 Dec Places
> >
> > But the same column on other worksheets have format of:
> > NumberFormat = "#,##0.00000_);(#,##0.00000)" 'Number with 5
> >
> > I format NumbToReplace as follows:
> > FilterCriteria = WorksheetFunction.Text(NumbToReplace, _
> > "#,##0.00_);(#,##0.00)")
> >
> > Then I set the filter:
> > Filter1.AutoFilter Field:=4, Criteria1:="=" & FilterCriteria
> >
> > The challenge: How to format "NumbToReplace" which becomes
> > "FilterCriteria" so that the filter is set properly no matter how many
> > decimal places the worksheet column has?
> >
> > I am having a can't-see-the-forest-for-the-trees-moment even though the
> > answer is probably staring me right in the face..
> >
> > TIA EagleOne

>
> --
>
> Dave Peterson


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
toggle between autofilter Criteria1:= "*" and "all" Mike Gallagher Microsoft Excel Programming 2 26th Dec 2007 07:02 PM
VB Question - AutoFilter related - 'Criteria1:' secion of my code Midnight Microsoft Excel Programming 6 13th Aug 2007 05:17 PM
Complex comparison of Columns of Data: Extracting unique records after comparison on 4 levels ap Microsoft Excel Programming 2 23rd Jan 2007 10:12 AM
Need help with Criteria1 =?Utf-8?B?VHJldmVyIEI=?= Microsoft Excel Programming 1 8th Jan 2007 08:49 AM
can I use a cell content as a Criteria1 reference in the below Selection.AutoFilter statement? prady Microsoft Excel Programming 1 28th Jul 2006 04:27 PM


Features
 

Advertising
 

Newsgroups
 


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