You have used userform1_Initialize and userform2_Initialize procedures to add items to Combobox2 and combobox3 but you didn't call them anywhere. Either write that code in UserForm_Initialize procedure or call these two procedures in UserForm_Initialize procedure.
Suggestion:
To fill the comboboxes,you add items to an array and then loop through the array to add items.You dont need to do that.It can be done in a single line.
e.g.
You can use the following snippet to disable the X button:Code:ComboBox2.List = Worksheets("Data").Range("B2:B15").Value
Addendum:Code:Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True End If End Sub
If you want to avoid all the loops while filling the comboboxes than you can use the following code:
Code:Private Sub UserForm_Initialize() ComboBox1.List = Evaluate("IF(ROW(1:15),TEXT(NOW()-8 + ROW(1:15),""mm-dd-yyyy""))") ComboBox2.List = Worksheets("Data").Range("B2:B15").Value ComboBox3.List = Worksheets("Data").Range("C2:C5").Value End Sub





Reply With Quote
Bookmarks