ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calendar Initialize (https://www.excelbanter.com/excel-programming/416033-calendar-initialize.html)

Patrick C. Simonds

Calendar Initialize
 
Is there any way in which this can be amended so that the date selected when
the calendar is displayed that the next Sunday is selected (unless the
current day is Sunday then I want the date to be the current date)



Private Sub UserForm_Initialize()

Calendar1 = Now()

End Sub


Gary Keramidas

Calendar Initialize
 
maybe something like this:

If Weekday(Date, vbSunday) = 1 Then
Calendar1 = Date
Else
Calendar1= Date + 8 - Weekday(Date, vbSunday)
End If

--


Gary


"Patrick C. Simonds" wrote in message
...
Is there any way in which this can be amended so that the date selected when
the calendar is displayed that the next Sunday is selected (unless the current
day is Sunday then I want the date to be the current date)



Private Sub UserForm_Initialize()

Calendar1 = Now()

End Sub




Rick Rothstein \(MVP - VB\)[_2650_]

Calendar Initialize
 
Try this...

Calendar1 = Now + (8 - Weekday(Now)) Mod 7

Rick


"Patrick C. Simonds" wrote in message
...
Is there any way in which this can be amended so that the date selected
when the calendar is displayed that the next Sunday is selected (unless
the current day is Sunday then I want the date to be the current date)



Private Sub UserForm_Initialize()

Calendar1 = Now()

End Sub




All times are GMT +1. The time now is 08:46 PM.

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