ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Microsoft Date and Time Picker control for User Form (https://www.excelbanter.com/excel-programming/434285-microsoft-date-time-picker-control-user-form.html)

Luke

Microsoft Date and Time Picker control for User Form
 
I found this handy little control recently and was wondering whether it is
possible to refer to a cell in a worksheet in the MaxDate field. This is for
a workbook I update every month and I don't want anyone to be able to select
a date that is past the end of the month. I know I can write a small test
for it, but I'd rather just use the MaxDate field. Can it be done that way?

Patrick Molloy[_2_]

Microsoft Date and Time Picker control for User Form
 
you can't set the property directly to a range, so do it when the form
initialises:

Private Sub UserForm_Initialize()
DTPicker1.MaxDate = Range("B2")
End Sub

where B2 is a date. Tested fine

"Luke" wrote:

I found this handy little control recently and was wondering whether it is
possible to refer to a cell in a worksheet in the MaxDate field. This is for
a workbook I update every month and I don't want anyone to be able to select
a date that is past the end of the month. I know I can write a small test
for it, but I'd rather just use the MaxDate field. Can it be done that way?


Luke

Microsoft Date and Time Picker control for User Form
 
Ahhh, that will work nicely. The more I learn about this stuff, the more I
realize there is so much I don't know.

Thanks for the quick response.

"Patrick Molloy" wrote:

you can't set the property directly to a range, so do it when the form
initialises:

Private Sub UserForm_Initialize()
DTPicker1.MaxDate = Range("B2")
End Sub

where B2 is a date. Tested fine

"Luke" wrote:

I found this handy little control recently and was wondering whether it is
possible to refer to a cell in a worksheet in the MaxDate field. This is for
a workbook I update every month and I don't want anyone to be able to select
a date that is past the end of the month. I know I can write a small test
for it, but I'd rather just use the MaxDate field. Can it be done that way?



All times are GMT +1. The time now is 07:23 AM.

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