ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inputbox Default to be Upcomming Sunday (https://www.excelbanter.com/excel-programming/365817-inputbox-default-upcomming-sunday.html)

Brian

Inputbox Default to be Upcomming Sunday
 
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


Brian

Inputbox Default to be Upcomming Sunday
 
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

Brian wrote:
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



Mark Driscol[_2_]

Inputbox Default to be Upcomming Sunday
 
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


Brian wrote:
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




All times are GMT +1. The time now is 10:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com