LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 41
Default Check input is a date

Hi, I have just started some very basic VB my code needs to check if cell I2
= "Enter Date" if it does it brings up an input box for the user to enter the
date. However just now the user can enter anything into this input box and
Excel will accept it. I would like it to reject anything that is not a
within the next or last 4 days and continue asking for a date before closing.
Can someone tell me how I would do this? My code is below. Thanks in
advance


Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim mydate As Range
Set mydate = Worksheets("Daily Sheet").Range("I2")
If mydate = "Enter Date" Then mydate = Application.InputBox(" No Date
Entered" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "
Enter Date now!", "Date not entered", Format(Date, "dd/mm/yyyy"))
mydate = Format(mydate, "DD/MM/YYYY")
End Sub
 
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
how can i set a date reminder to check on something in a certain. vette Excel Worksheet Functions 1 November 7th 06 04:56 PM
How to Input date & Time [NOW()], then stop it updating? jonathandr Excel Worksheet Functions 3 October 23rd 06 05:41 PM
How can I check a cell for current date and insert it if blank? Don K New Users to Excel 3 September 29th 06 02:46 PM
Countif and date check for second criteria [email protected] Excel Worksheet Functions 0 November 29th 05 09:40 PM
date year input LIVE SANDY Excel Discussion (Misc queries) 2 September 27th 05 03:13 AM


All times are GMT +1. The time now is 03:12 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"