P
Przemek Wrzesinski
Hi,
I've got a problem with implementing Date function into combobox. I've got 3
comboboxes in my user form, one combo for day, second one for month and last
one for year. I know that I can add item to combobox via .AddItem method but
after this I want set the values (listindex) of these combo's to system
date, instead of clicking by user, something like this:
Dim IssueDate As Date
Dim IssueDateYear As Long
Dim IssueDateMonth As Long
Dim IssueDateDay As Long
Set IssueDate = Date
Set IssueDateMonth = Month(IssueDate)
With myform.IssueDateMonthCombobox
.Clear
.AddItem (IssueDateMonth-1) ' last month
.AddItem (IssueDateMonth)
.AddItem (IssueDateMonth+1) 'next month
.ListIndex = ' set to IssueDateMonth
End With
When I'm trying to run this, Excel is saying "object required' and marking
line "Set IssueDateMonth = " and "Private Sub UserForm_Initialize()" :-/
Has anyone dealt with this ?
TIA
Przemek
I've got a problem with implementing Date function into combobox. I've got 3
comboboxes in my user form, one combo for day, second one for month and last
one for year. I know that I can add item to combobox via .AddItem method but
after this I want set the values (listindex) of these combo's to system
date, instead of clicking by user, something like this:
Dim IssueDate As Date
Dim IssueDateYear As Long
Dim IssueDateMonth As Long
Dim IssueDateDay As Long
Set IssueDate = Date
Set IssueDateMonth = Month(IssueDate)
With myform.IssueDateMonthCombobox
.Clear
.AddItem (IssueDateMonth-1) ' last month
.AddItem (IssueDateMonth)
.AddItem (IssueDateMonth+1) 'next month
.ListIndex = ' set to IssueDateMonth
End With
When I'm trying to run this, Excel is saying "object required' and marking
line "Set IssueDateMonth = " and "Private Sub UserForm_Initialize()" :-/
Has anyone dealt with this ?
TIA
Przemek