Avatar of RobStl
RobStl
Flag for United States of America asked on

Excel Date Format Issue: Treating Date as a Number

Hello,

I am having an issue when filtering a column to search for all 2011 and 2012 dates.  Here is my current code:
assessSheet.Range("$A$1:$BG$2000").AutoFilter Field:=9, Criteria1:="=*2012*" _
        , Operator:=xlOr, Criteria2:="=*2011*"

Open in new window


This generally works fine, but when I add new rows of data to the end of my spreadsheet, the dates will not format correctly.  I have tried copying the format of the correct rows to the rows with the issue, but it still will not work.  I also noticed that the correct dates' format appears to be different from the issue dates' format. (See attached images).
Format of the rows with issuesFormat of the correct rows
Also, when I open the "More Number Formats", both of them are on the same format as seen in the following image: More Number Formats Properties Box
I am not sure how to fix this issue.. even though it seems pretty simple.  I am not able to share my spreadsheet either..  Does someone know how to fix this issue?

Thanks in advance,
Rob
Microsoft Excel

Avatar of undefined
Last Comment
Rory Archibald

8/22/2022 - Mon
Norie

Rob

How are you adding data?
RobStl

ASKER
By typing in the date.  ie: I type in "2/15/12" and it will format it to "2/15/2012".  However, when I filter the data, that row does not appear in the filter.
RobStl

ASKER
Hmmm, it appears that when I switch the data to a text, then type "2/15/12", then convert it to a date, it works correctly.  I'm not quite sure why though..
Your help has saved me hundreds of hours of internet surfing.
fblack61
RobStl

ASKER
However, I am not the only person adding data to this spreadsheet, so this will not work for me.  I need the spreadsheet to accept dates in the correct format as new dates are added to that column.
ASKER CERTIFIED SOLUTION
Rory Archibald

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.