Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Macro with custom autofilter for greater and less than specific da

Hi

I am trying to record a macro where I autofilter a column containing dates.
I need to apply greater than and less than to get a specific month eg.
greater than 11/01/06 and less than 11/30/06 to get the info for the month of
november. When I record the macro and run it I find that there is no data
displayed yet when I autofilter without the help of a macro then the
information is there. Anyone have any ideas what I'm doing wrong?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro with custom autofilter for greater and less than specific da

I'm not sure how you're getting the date, but sometimes making sure it's a Long
will help:

.Range("a1").CurrentRegion.AutoFilter Field:=3, _
Criteria1:="=" & CLng(CDate(UserVal))

Sometimes using the same numberformat helps:

.Range("a1").CurrentRegion.AutoFilter Field:=3, _
Criteria1:="=" & Format(CDate(UserVal),"mm/dd/yyyy")

(try it for both dates)



Peter-Jon wrote:

Hi

I am trying to record a macro where I autofilter a column containing dates.
I need to apply greater than and less than to get a specific month eg.
greater than 11/01/06 and less than 11/30/06 to get the info for the month of
november. When I record the macro and run it I find that there is no data
displayed yet when I autofilter without the help of a macro then the
information is there. Anyone have any ideas what I'm doing wrong?


--

Dave Peterson
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



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