EXCEL: Custom Filter Macro

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

ljzmcm

Thread Starter
Joined
Apr 28, 2008
Messages
148
Hey all,

I have a custom filter that does:

Greater than or equal too: (date here)

AND

Less than or equal too: (another date)

I recorded the macro, but I want to put the two dates from a cell

this is all wrong, but maybe you can see where I'm going with this:

Sub CustomFilter()
'
' CustomFilter Macro
'
' Keyboard Shortcut: Ctrl+j
'
Selection.AutoFilter Field:=4, Criteria1:=">=(Range("H3").Value)", Operator:=xlAnd _
, Criteria2:="<=(Range("J3").Value)"
End Sub

Should be simple... Any help, please?
 
Joined
Jul 1, 2005
Messages
8,546
First thing, your syntax is off.

Selection.AutoFilter Field:=4, Criteria1:=">=" & Range("H3"), _
Operator:=xlAnd, Criteria2:="<=" & Range("J3")


That works for me if Field4 (column D?) and H3/J3 are plain numbers.

Of course, in Excel dates are plain numbers. So possibly the second thing is are you outside the US. Manipulating dates in VBA can be troublesome because Excel tends to think dates in US format.

Where are you going with this? Presumably a macro to filter by dates can't be all you're aiming for.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top