#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default help on date

Here is a hard one i have been stuckon for a while. I have a user form that
does a now statemnet to automatically fill a text box. However a user can
input a another date in the date issued textbox. What i want it to do is if
that date that the user enters in is to old then it iwll pop a msgbox up.

For example this being October can you have the date limit allow input for
August, September and October and flag any with dates before August as too
old to accept? Now this will have to be an xpression that will update from
the now statement. So if its now month is November then it will allow info
for November, October and September but flag any past dates. I know this is a
wierd one but i thought i was getting good at programming till this happend.
Thanks for anyone hlp on this.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default help on date

I didn't build a userform, but this kind of thing may help:

Option Explicit
Sub testme()
Dim myDate As Date
Dim CutOffDate As Date

On Error Resume Next
myDate = CDate(InputBox(Prompt:="Enter any date", _
Default:=Format(Date, "mmmm dd, yyyy")))
If Err.Number < 0 Then
MsgBox "not a date"
Err.Clear
Exit Sub
End If

CutOffDate = DateSerial(Year(Date), Month(Date) - 2, 1)

If myDate < CutOffDate Then
MsgBox "too early"
Else
'do the work
End If
End Sub

mikester104 wrote:

Here is a hard one i have been stuckon for a while. I have a user form that
does a now statemnet to automatically fill a text box. However a user can
input a another date in the date issued textbox. What i want it to do is if
that date that the user enters in is to old then it iwll pop a msgbox up.

For example this being October can you have the date limit allow input for
August, September and October and flag any with dates before August as too
old to accept? Now this will have to be an xpression that will update from
the now statement. So if its now month is November then it will allow info
for November, October and September but flag any past dates. I know this is a
wierd one but i thought i was getting good at programming till this happend.
Thanks for anyone hlp on this.


--

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
insert date Larry Excel Worksheet Functions 28 July 15th 06 02:41 AM
Insert Automatic, Non-Updating Date Stamp Ken Zenachon Excel Discussion (Misc queries) 8 January 18th 06 06:52 PM
Calculate 1st of month date from existing date. Jim15 Excel Discussion (Misc queries) 1 January 9th 06 10:05 PM
Need to Improve Code Copying/Pasting Between Workbooks David Excel Discussion (Misc queries) 1 January 6th 06 03:56 AM
Another Date issue. TimM Excel Worksheet Functions 1 November 17th 05 01:58 AM


All times are GMT +1. The time now is 02:12 PM.

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"