Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Filter column using criteria from a userform

I would like to filter a column based on criteria entered
into a userform. I've got this code so far using actual
dates:
Selection.AutoFilter Field:=51, Criteria1:="=01/06/2003",
Operator:= _
xlAnd, Criteria2:="<=30/10/2003"

BUT, I want to substitute the dates for variables that
come from a date picker on the userform, ie =variablename
I've tried:
Criteria1:= = variablename
Criteria1:= "=" variablename
Criteria1:= "=variablename" - this picks up the words,
not the variable

But none of them work - what syntax do I use?

Please help.
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Filter column using criteria from a userform

Use an ampersand to join the operator and variable:

Selection.AutoFilter Field:=51, Criteria1:="=" & Variable1, _
Operator:=xlAnd, Criteria2:="<=" & Variable2


Eileen wrote:
I would like to filter a column based on criteria entered
into a userform. I've got this code so far using actual
dates:
Selection.AutoFilter Field:=51, Criteria1:="=01/06/2003",
Operator:= _
xlAnd, Criteria2:="<=30/10/2003"

BUT, I want to substitute the dates for variables that
come from a date picker on the userform, ie =variablename
I've tried:
Criteria1:= = variablename
Criteria1:= "=" variablename
Criteria1:= "=variablename" - this picks up the words,
not the variable

But none of them work - what syntax do I use?

Please help.
Thanks



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

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
Filter duplicates based on criteria / column values phillr Excel Discussion (Misc queries) 0 April 9th 10 09:13 PM
Find record by multi criteria in userform MP Excel Discussion (Misc queries) 0 November 3rd 08 04:01 PM
filter or format based on criteria in more than one column tabbicat Excel Worksheet Functions 4 March 13th 07 02:24 PM
"Criteria Range" in the "Data/Filter/Advanced Filter" to select Du TC Excel Worksheet Functions 1 May 12th 05 02:06 AM


All times are GMT +1. The time now is 01:03 PM.

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"