Inputbox Default to be Upcomming Sunday

B

Brian

I have a input box that is looking for a date.

DT = InputBox("Enter New Date: ", Date)

I would like have the default value of the inputbox as the upcomming
sunday( Today is 6-29-06 default value should show 7-2-06)

Thanks in advance
 
B

Brian

I figured it out by using the following code

Sub sunday()


If Weekday(Date) = vbSunday Then
DaT = Date

ElseIf Weekday(Date) = vbMonday Then
DaT = Date + 6

ElseIf Weekday(Date) = vbTuesday Then
DaT = Date + 5

ElseIf Weekday(Date) = vbWednesday Then
DaT = Date + 4

ElseIf Weekday(Date) = vbThursday Then
DaT = Date + 3

ElseIf Weekday(Date) = vbFriday Then
DaT = Date + 2

ElseIf Weekday(Date) = vbSaturday Then
DaT = Date + 1


End If
End Sub
 
M

Mark Driscol

Sub Temp()

Dim intDOW As Integer
Dim DT As String
Dim datNewDate As Date

intDOW = Weekday(Date, vbSunday)
datNewDate = Date + (7 - intDOW + 1)

DT = InputBox("Enter New Date: ", datNewDate)
' The rest of your code goes here

End Sub

Note that to display the next Sunday in the InputBox, not its title,
you would use


DT = InputBox("Enter New Date: ", , datNewDate)

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top