Date format in Macro - TechRepublic
Question
July 15, 2009 at 03:45 AM
lance1234

Date format in Macro

by lance1234 . Updated 17 years ago

I am a newby in macro and would like to create a Macro in Excel that would note the date today and tomorrow via format mm/dd only, place it in a cell, which will later be copied to become an input as the filter category for a specific column. I was able to come up with a script (below) however, the date that was being used has a format of mm/dd/yyyy, which causes the filter to return 0 column since it did not satisfy the filter criteria. Kindly help me resolve this. Thanks.

Macro Script:

Range(“Z3:Z4”).Select
Selection.NumberFormat = “mm/dd;@”
Range(“Z3”).Select
ActiveCell.Value = Int(Now())
Range(“Z4”).Select
ActiveCell.Value = Int(Now + 1)

Range(“A1”).Select
Selection.AutoFilter
Selection.AutoFilter Field:=5, Criteria1:=Range(“Z3”).Value, Operator:=xlOr, _
Criteria2:=Range(“Z4”).Value

This discussion is locked

All Comments