0

I want to add unique data (From MainMenuData worksheet in same workbook) into ActiveX combo box placed on sheet1. Changed ComboBox Name from Properties to ZoneDropDown. Wrote following code on workbook open event.

Private Sub workbook_open()

Dim Zn()

Dim R As Integer

For R = 1 To 248

    ZoneDropDown.AddItem Sheets("MainMenuData").Cells(R, 7)

Next

End Sub

It gives following error for ZoneDropDown

Microsoft Visual Basic for Applications
Compile error:

Variable not defined

But if I place button on same worksheet (i.e. sheet1) above code execute successfully and data added into combo box.

2
  • You have not defined Dim Zn() as anything (integer, string, etc.). What is it for? If you remark it out, does the code work?
    – CharlieRB
    Jan 19, 2016 at 14:47
  • Insted of ZoneDropDown.AddItem Sheets("MainMenuData").Cells(R, 7) I change to Sheets("Sheet1").ZoneDropDown.AddItem Sheets("MainMenuData").Cells(R, 7) & it works
    – curious K
    Jan 19, 2016 at 14:48

0

You must log in to answer this question.

Browse other questions tagged .