Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Date Criteria in Excel Macro


Hello,
Does anyone know how to set up a date in a Macro so that it allows me
to put in a date when I run the Macro. When I created the macro I
created it with a criteria for a September but at the end of month I
will need to capture the data for October and so on. Is there a way to
change the dates other than manually going into the macro every month
and changing them? Listed below is the structure of the dates using
the Macro recorder:

Selection.AutoFilter Field:=37, Criteria1:="=9/5/2005",
Operator:=xlAnd _
, Criteria2:="<=10/2/2005"

How should I change the code so that it look at a new set of dates
every month?

Any help is appreciated.


--
Lizz45ie
------------------------------------------------------------------------
Lizz45ie's Profile: http://www.excelforum.com/member.php...o&userid=23410
View this thread: http://www.excelforum.com/showthread...hreadid=479917

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Date Criteria in Excel Macro


Hello Lizz45ie,

Add 2 InputBoxes to your macro code to ask for the starting and ending
dates, like this...


Starting = InputBox("Enter Starting Date as m/d/yyyy")
Ending = InputBox("Enter Ending Date as m/d/yyyy")

Selection.AutoFilter Field:=37, Criteria1:= Starting, Operator:=xlAnd
_
, Criteria2:= Ending

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=479917

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Date Criteria in Excel Macro


Leith,
I made the changes to the Macro and it prompts me for dates but it does
not return any data using that format. I changed the date to reflect
the date format thinking that may make different but it didn't. I know
there is data for that time frame because it worked when I hard-coded
the dates in the Macro. Do you have any idea why that isn't working?

thanks in advance.


--
Lizz45ie
------------------------------------------------------------------------
Lizz45ie's Profile: http://www.excelforum.com/member.php...o&userid=23410
View this thread: http://www.excelforum.com/showthread...hreadid=479917

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Date Criteria in Excel Macro


Hi Lizzie,

Not sure if this is right, but shouldn't Leigh's macro include the
greater than/less than for the criteria?

Thanks

Andy

Lizz45ie wrote:
Leith,
I made the changes to the Macro and it prompts me for dates but it does
not return any data using that format. I changed the date to reflect
the date format thinking that may make different but it didn't. I know
there is data for that time frame because it worked when I hard-coded
the dates in the Macro. Do you have any idea why that isn't working?

thanks in advance.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Date Criteria in Excel Macro


Hello Lizz45ie,

First I want to apologize to you for having left out the comparison
operators. Secondly, thanks to Andy for catching my mistake. Thank you
for bringing it to my atttention. Again my apologies for the code error
and any inconveniece it has caused.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=479917

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
Macro filter based on date criteria puiuluipui Excel Discussion (Misc queries) 4 September 19th 09 12:18 PM
Formula in excel using date criteria Pempa Excel Discussion (Misc queries) 2 March 16th 07 05:49 PM
Reg autofiltering using macro in excel with out providing criteria Juno Excel Worksheet Functions 4 May 28th 06 05:48 PM
how to use lookup a value by date for criteria in Excel sheet dom Excel Worksheet Functions 5 January 11th 05 04:22 AM
Excel VBA to search all macro code in Excel module for specific string criteria Roger1947 Excel Programming 0 May 19th 04 05:51 PM


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