Initilizing the New DropDown feature

P

Philosophaie

Having a little trouble initilizing the New DropDown1 that came up when I
inserted the ComboBox (Form Control). Here is the code used in ThisWokbook:

Private Sub Workbook_Open()
With DropDown1
.AddItem "Current Date"
.AddItem "Enter Date"
.Caption "Select Date Type"
End With
End Sub

It didn't like the (.AddItem "Current Date") and marked it in yellow for
debug. Can someone help me with the syntax?
 
N

Nigel

A couple of things if it is a form control then the code is not applicable!
Set the format of the control as required

If you use an Active X Control
1. You need to explicitly reference the ComboBox location, e.g. code below
on Sheet1
2. There is no caption property for a ComboBox, if you are trying to set the
control to the first entry, use

..ListIndex = 0

Private Sub Workbook_Open()
With Worksheets("Sheet1").ComboBox1
.AddItem "Current Date"
.AddItem "Enter Date"
'.Caption "Select Date Type"
End With
End Sub
 
P

Philosophaie

Got it to work with:

Private Sub Workbook_Open()
With ActiveSheet.Shapes("Drop Down 2").ControlFormat
.AddItem "Current Date"
.AddItem "Enter Date"
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top