PC Review


Reply
Thread Tools Rate Thread

Check data item is date not text format

 
 
=?Utf-8?B?SmltYm9i?=
Guest
Posts: n/a
 
      3rd Aug 2007
I have a macro which calculates anniversary and other follow up dates from a
given date in a spreadsheet. There is a prompt in the source cell, but users
repeatedly enter the date as a string (3rd Aug 07 instead of 3/8/07). I
would use a formula like T(A1)=””, TRUE,FALSE to check whether the date is in
string or date format but how do I achieve this programmatically before
sending a message box to the user to change the format?

Thanks a lot
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWljaGFlbA==?=
Guest
Posts: n/a
 
      3rd Aug 2007
Set up a validation check:
From the Data toolbar menu select:

Data -> Validation; allow Date from the dropdown
And select greater than.
You can also add a custom message to specify the type of data required, plus
format the cells in a specific manner.

Regards,

Michael Arch.


"Jimbob" wrote:

> I have a macro which calculates anniversary and other follow up dates from a
> given date in a spreadsheet. There is a prompt in the source cell, but users
> repeatedly enter the date as a string (3rd Aug 07 instead of 3/8/07). I
> would use a formula like T(A1)=””, TRUE,FALSE to check whether the date is in
> string or date format but how do I achieve this programmatically before
> sending a message box to the user to change the format?
>
> Thanks a lot

 
Reply With Quote
 
=?Utf-8?B?SmltYm9i?=
Guest
Posts: n/a
 
      3rd Aug 2007
Thanks for responding Michael. I understand data validation but the
spreadsheet my macro works on isn't of my design and can't be changed too
redaily as you suggest. My macro works on the sheet once it comes to me.
What I need to do is verify the date is in the correct format or send a
prompt to the user to change it. I imagined using "If . . Then" but can't
get the code for the formula I'd use in Excel before generating the message
box.

"Michael" wrote:

> Set up a validation check:
> From the Data toolbar menu select:
>
> Data -> Validation; allow Date from the dropdown
> And select greater than.
> You can also add a custom message to specify the type of data required, plus
> format the cells in a specific manner.
>
> Regards,
>
> Michael Arch.
>
>
> "Jimbob" wrote:
>
> > I have a macro which calculates anniversary and other follow up dates from a
> > given date in a spreadsheet. There is a prompt in the source cell, but users
> > repeatedly enter the date as a string (3rd Aug 07 instead of 3/8/07). I
> > would use a formula like T(A1)=””, TRUE,FALSE to check whether the date is in
> > string or date format but how do I achieve this programmatically before
> > sending a message box to the user to change the format?
> >
> > Thanks a lot

 
Reply With Quote
 
=?Utf-8?B?SmltYm9i?=
Guest
Posts: n/a
 
      4th Aug 2007
I've now worked out some code which seems to work:
Dim ADate
Worksheets("Summary").Range("E4").Activate
ADate = ActiveCell
If IsDate(ADate) Then
Else
Response = MsgBox("blah, blah, blah", vbCritical, "WARNING")
End If
End Sub

Is this foolproof or should it be cleverer?

Cheers

"Jimbob" wrote:

> I have a macro which calculates anniversary and other follow up dates from a
> given date in a spreadsheet. There is a prompt in the source cell, but users
> repeatedly enter the date as a string (3rd Aug 07 instead of 3/8/07). I
> would use a formula like T(A1)=””, TRUE,FALSE to check whether the date is in
> string or date format but how do I achieve this programmatically before
> sending a message box to the user to change the format?
>
> Thanks a lot

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Additional value is added to date value or time value after exportingaccess data to text format rajamarzuki@trg.moh.gov.my Microsoft Access 2 29th Jan 2009 02:16 PM
Convert a column of data from Text to date format Dave K Microsoft Excel Discussion 2 16th Sep 2008 09:31 PM
Macro to Change Changing Date Format Data to Text =?Utf-8?B?Um9kIEJvd3llcg==?= Microsoft Excel Misc 3 11th Oct 2007 12:02 PM
Cell format with Data Import (date appearing as text) =?Utf-8?B?TG91aXNl?= Microsoft Excel Misc 3 21st Sep 2006 01:57 PM
code to convert date from TEXT format (03-02) to DATE format (200203) Gauthier Microsoft Excel Programming 0 22nd Sep 2004 03:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:48 PM.