Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
Modify general format to date format. SherryS Excel Worksheet Functions 2 April 27th 10 01:34 PM
Change General format to Date format Vic Excel Discussion (Misc queries) 2 May 2nd 09 09:41 AM
Date format for general formatting rrupp Excel Discussion (Misc queries) 5 July 15th 08 10:19 PM
changing date formatted as general number into date format pghio Excel Programming 4 March 2nd 07 05:17 PM
Change general format to US date format woodlot4 Excel Discussion (Misc queries) 3 October 11th 05 12:29 AM


All times are GMT +1. The time now is 11:10 AM.

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"