G
Guest
Hi
I want a user to select a year 2001 to 2010, and then based on this
selection choose a (Friday) weekend date. Other calculations are dependant
upon the results from this last selection.
I can do this without programming using data validation and the indirect
function. However I wanted to try to do it using combo boxes.
In the past I have only used the combo box from the forms toolbar and the
input range does not recognise the INDIRECT function, or at least does not
behave in the same way as data validation.
When using the combo box from the control toolbox toolbar the indirect
function does not appear to work when =INDIRECT is entered in the
ListFillRange box in properties.
I searched the discussion groups for a solution and I was directed to
www.xldynamic.com/source/xld.Dropdowns.html from multiple postings.
I copied / imported all of the code and modified it to meet my requirements
re worksheet names (I replaced “data†with “WeekEndingDatesâ€) in the module
mComboMaintain and elsewhere as required.
When I open the workbook, after a while an error message appears
Compile error, variable not defined.
When debugging “combo†is highlighted in blue in the line
“With combo.cboPrimaryâ€
The complete code is given below. Can anyone indicate where I need to look?
Regards
Phil Smith
Option Explicit
'---------------------------------------------------------------------
Public Function fzPopulatList1()
'---------------------------------------------------------------------
Dim i As Long
Application.EnableEvents = False
'On Error GoTo pl1_exit
With combo.cboPrimary
.Clear
For i = 2 To Range(kList1Hnd).Count + 1
.AddItem WeekEndingDates.Cells(1, i).Value
Next i
Application.EnableEvents = True
.ListIndex = 0
End With
pl1_exit:
Application.EnableEvents = True
End Function
I want a user to select a year 2001 to 2010, and then based on this
selection choose a (Friday) weekend date. Other calculations are dependant
upon the results from this last selection.
I can do this without programming using data validation and the indirect
function. However I wanted to try to do it using combo boxes.
In the past I have only used the combo box from the forms toolbar and the
input range does not recognise the INDIRECT function, or at least does not
behave in the same way as data validation.
When using the combo box from the control toolbox toolbar the indirect
function does not appear to work when =INDIRECT is entered in the
ListFillRange box in properties.
I searched the discussion groups for a solution and I was directed to
www.xldynamic.com/source/xld.Dropdowns.html from multiple postings.
I copied / imported all of the code and modified it to meet my requirements
re worksheet names (I replaced “data†with “WeekEndingDatesâ€) in the module
mComboMaintain and elsewhere as required.
When I open the workbook, after a while an error message appears
Compile error, variable not defined.
When debugging “combo†is highlighted in blue in the line
“With combo.cboPrimaryâ€
The complete code is given below. Can anyone indicate where I need to look?
Regards
Phil Smith
Option Explicit
'---------------------------------------------------------------------
Public Function fzPopulatList1()
'---------------------------------------------------------------------
Dim i As Long
Application.EnableEvents = False
'On Error GoTo pl1_exit
With combo.cboPrimary
.Clear
For i = 2 To Range(kList1Hnd).Count + 1
.AddItem WeekEndingDates.Cells(1, i).Value
Next i
Application.EnableEvents = True
.ListIndex = 0
End With
pl1_exit:
Application.EnableEvents = True
End Function