Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default autofilter with variable criteria

I have the following programming attempting to use the variable CBOX as my
Criteria1 in an autofilter. I get a syntax error on the autofilter line when
i run it. The line works fine if I use "=" as opposed to the "<" which i
want. I am attempting to filter away the variable in CBOX.

========================
Private Sub CheckBox3_Click()
Dim cbox As String
Let cbox = CheckBox3.Caption

If CheckBox3 = False Then
Selection.AutoFilter Field:=40, Criteria1:<cbox

Else
Selection.AutoFilter Field:=40
End If

End Sub

========================
thanks,
dr chuck
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default autofilter with variable criteria

there is a difference between the < operator and the assignment operator
for an argument. You can't do :<


Selection.AutoFilter Field:=40, Criteria1:="<"&cbox


--
Regards,
Tom Ogilvy




"dr chuck" wrote in message
...
I have the following programming attempting to use the variable CBOX as my
Criteria1 in an autofilter. I get a syntax error on the autofilter line
when
i run it. The line works fine if I use "=" as opposed to the "<" which i
want. I am attempting to filter away the variable in CBOX.

========================
Private Sub CheckBox3_Click()
Dim cbox As String
Let cbox = CheckBox3.Caption

If CheckBox3 = False Then
Selection.AutoFilter Field:=40, Criteria1:<cbox

Else
Selection.AutoFilter Field:=40
End If

End Sub

========================
thanks,
dr chuck



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default autofilter with variable criteria

Thanks Tom,
You always supply a wealth of information.
--
dr chuck


"Tom Ogilvy" wrote:

there is a difference between the < operator and the assignment operator
for an argument. You can't do :<


Selection.AutoFilter Field:=40, Criteria1:="<"&cbox


--
Regards,
Tom Ogilvy




"dr chuck" wrote in message
...
I have the following programming attempting to use the variable CBOX as my
Criteria1 in an autofilter. I get a syntax error on the autofilter line
when
i run it. The line works fine if I use "=" as opposed to the "<" which i
want. I am attempting to filter away the variable in CBOX.

========================
Private Sub CheckBox3_Click()
Dim cbox As String
Let cbox = CheckBox3.Caption

If CheckBox3 = False Then
Selection.AutoFilter Field:=40, Criteria1:<cbox

Else
Selection.AutoFilter Field:=40
End If

End Sub

========================
thanks,
dr chuck




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 criteria not yet known JeffMelton Excel Programming 1 July 25th 06 08:12 AM
AutoFilter criteria Mark Excel Programming 1 November 2nd 05 12:08 PM
AutoFilter Criteria VBA EstherJ Excel Programming 2 August 20th 04 12:54 PM
Variable in AutoFilter criteria morry[_28_] Excel Programming 1 June 30th 04 04:48 AM
VBA Autofilter Criteria Brandon[_5_] Excel Programming 1 November 7th 03 12:40 PM


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