Solved

Excel Date Format Issue: Treating Date as a Number

Posted on 2012-03-12
5
160 Views
Last Modified: 2012-03-19
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
0
Comment
Question by:RobStl
  • 3
5 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 37711897
Rob

How are you adding data?
0
 

Author Comment

by:RobStl
ID: 37711903
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.
0
 

Author Comment

by:RobStl
ID: 37711910
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..
0
 

Author Comment

by:RobStl
ID: 37711925
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.
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 300 total points
ID: 37711936
You can format the entire column as Text in advance. The type of filter criteria you are using will not work with actual dates.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now