Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
General vs Date format question
Using 2007 (but need compatibility with 2003)
I want the "look" at what was entered - if the date contains "slashes" leave it alone - if not, add the slashes. My main concern is to know what is the "format" in data entered (regardless on how the cell is formatted) - I can add the slashes as needed. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
General vs Date format question
First, rember a date is a positive number. So when you do ISDARE() it is
checking for a valid number that can be any date after Jan 1, 1900 which equals 1. You really want to check the numberformat property like this Set MyCell = Range("A1") Dateformat = MyCell.NumberFormat If InStr(Dateformat, "/") = 0 Then 'check if the number format contains a slash 'enter your code here End If "Brad" wrote: Using 2007 (but need compatibility with 2003) I want the "look" at what was entered - if the date contains "slashes" leave it alone - if not, add the slashes. My main concern is to know what is the "format" in data entered (regardless on how the cell is formatted) - I can add the slashes as needed. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
General vs Date format question
First, remember a date is a positive number. So when you do ISDARE() it is
checking for a valid number that can be any date after Jan 1, 1900 which equals 1. You really want to check the numberformat property like this Set MyCell = Range("A1") Dateformat = MyCell.NumberFormat If InStr(Dateformat, "/") = 0 Then 'check if the number format contains a slash 'enter your code here End If "Brad" wrote: Using 2007 (but need compatibility with 2003) I want the "look" at what was entered - if the date contains "slashes" leave it alone - if not, add the slashes. My main concern is to know what is the "format" in data entered (regardless on how the cell is formatted) - I can add the slashes as needed. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
General vs Date format question
?isdate(clng(date))
False IsDate checks to see if the expression can be converted to a date. It can be a string or a real date. Joel wrote: First, rember a date is a positive number. So when you do ISDARE() it is checking for a valid number that can be any date after Jan 1, 1900 which equals 1. You really want to check the numberformat property like this Set MyCell = Range("A1") Dateformat = MyCell.NumberFormat If InStr(Dateformat, "/") = 0 Then 'check if the number format contains a slash 'enter your code here End If "Brad" wrote: Using 2007 (but need compatibility with 2003) I want the "look" at what was entered - if the date contains "slashes" leave it alone - if not, add the slashes. My main concern is to know what is the "format" in data entered (regardless on how the cell is formatted) - I can add the slashes as needed. -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
General vs Date format question
I'd start at Chip Pearson's site:
http://cpearson.com/excel/DateTimeEntry.htm Brad wrote: Using 2007 (but need compatibility with 2003) I want the "look" at what was entered - if the date contains "slashes" leave it alone - if not, add the slashes. My main concern is to know what is the "format" in data entered (regardless on how the cell is formatted) - I can add the slashes as needed. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Modify general format to date format. | Excel Worksheet Functions | |||
Change General format to Date format | Excel Discussion (Misc queries) | |||
Date format for general formatting | Excel Discussion (Misc queries) | |||
changing date formatted as general number into date format | Excel Programming | |||
Change general format to US date format | Excel Discussion (Misc queries) |