Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default InputBox requesting dates between two predefined dates

I'm trying to figure out how to display this programmatically for the user.
I want the user to enter a date between the following two dates:

Date 1 is defined as SummaryMin
Date 2 is defined named variable CPI_SPI_PITD_LastMo

I want them to enter the date they want to use (or select one of the two).
How would y'all approach this.

Thanks in advance,
Barb Reinhardt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default InputBox requesting dates between two predefined dates

Barb,
Perhaps something along these lines. For this example, I set
SummaryMin as the default date.

Sub InForm()

Dim SummaryMin As Date, CPI_SPI_PITD_LastMo As Date, GetDate as Date

SummaryMin = "01/01/2006"
CPI_SPI_PITD_LastMo = "31/01/2006"

Do
getDate = DateValue(Application.InputBox("Enter Date between " & SummaryMin
& " and " & CPI_SPI_PITD_LastMo, "Title date ", SummaryMin, Type:=2))
If getDate = "False" Then Exit Sub ' Cancel
If Not Application.And(getDate = SummaryMin, getDate <=
CPI_SPI_PITD_LastMo) Then
MsgBox "Invalid date. Please re-enter"
End If
Loop Until Application.And(getDate = SummaryMin, getDate <=
CPI_SPI_PITD_LastMo)
End Sub

"Barb Reinhardt" wrote:

I'm trying to figure out how to display this programmatically for the user.
I want the user to enter a date between the following two dates:

Date 1 is defined as SummaryMin
Date 2 is defined named variable CPI_SPI_PITD_LastMo

I want them to enter the date they want to use (or select one of the two).
How would y'all approach this.

Thanks in advance,
Barb Reinhardt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default InputBox requesting dates between two predefined dates

One way:

(Your post is a bit confusing - do you want to "enter a date between the
following two dates", or "select one of the two"? I assumed the former:

Const SummaryMin = #1/1/2006#
Const CPI_SPI_PITD_LastMo = #12/31/2006#
Dim vResult As Variant
Dim dtFirst As Date
Dim dtLast As Date
dtFirst = SummaryMin
dtLast = CPI_SPI_PITD_LastMo
Do
vResult = Application.InputBox( _
Prompt:="Enter a date between " & dtFirst & _
" and " & dtLast & ":", _
Title:="Enter Date", _
Default:=dtFirst, _
Type:=1)
If vResult = False Then Exit Sub 'user cancelled
vResult = vResult - ActiveWorkbook.Date1904 * 1462
Loop Until (vResult = dtFirst) And (vResult <= dtLast)
'Rest of macro
MsgBox "Valid date!"


In article ,
"Barb Reinhardt" wrote:

I'm trying to figure out how to display this programmatically for the user.
I want the user to enter a date between the following two dates:

Date 1 is defined as SummaryMin
Date 2 is defined named variable CPI_SPI_PITD_LastMo

I want them to enter the date they want to use (or select one of the two).
How would y'all approach this.

Thanks in advance,
Barb Reinhardt

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
Linking computer dates (time) to spreadsheet dates that have formu bigisle Excel Worksheet Functions 3 January 3rd 10 08:05 PM
Toggle a range of Julian dates to Gregorian Dates and Back PSKelligan Excel Programming 4 May 8th 07 05:51 AM
How do I get dates into an inputbox ? Sfekke Excel Programming 1 November 24th 05 08:32 AM
Entering dates in vba inputbox as ddmmyy. Excel returns mmddyy pkeegs Excel Programming 3 August 30th 05 08:57 AM
Requesting formula help for dates/years Mark[_53_] Excel Programming 1 November 9th 04 07:30 AM


All times are GMT +1. The time now is 01:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"