View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Nick Hodge Nick Hodge is offline
external usenet poster
 
Posts: 1,173
Default Using Controls on a Worksheet

What property of the combobox are you looking to use, as all your examples
don't show one and Excel may be considering it an undeclared variable as a
consequence. If you are looking to reference it from an object variable,
then you need to declare and set it

This code works *in a standard module* (It doesn't need to be in the
worksheet class module as intimated by another poster)

Sub AddressComboBox()
Dim myCombo As ComboBox
Set myCombo = Worksheets("Sheet1").ComboBox1
With myCombo
.Enabled = True
.List = Array("ListItem1", "ListItem2", "ListItem3")
End With
End Sub

I guess you are using a combobox from the 'Control' toolbox (ActiveX) and
not from the 'Forms' toolbox?

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HIS


"lurker111" wrote in message
...
I have tried that as well.

activeworkbook.worksheets("Sheet1").PMCombo
worksheets("Sheet1").PMCombo
Worksheets(1).PMCombo
dim wksht as worksheet
set wksht = activeworkbook.worksheets("sheet1")
wksht.PMCombo

None of the above works. I am always told that PMCombo is not a declared
variable or is not ...not a member? (I don't remember the exact error
message)

I may just have a single button pop up a Userform window. Execute that
window and then close down. Then when the user wants to enter in more
data
they just have to keep popping up the window. I want to have it so that
they
don't have to keep popping up a window though as it makes entering
multiple
sets of data more tedious.

"Nick Hodge" wrote:
Use ActiveSheet of explicitly address a worksheet like

Sub addressComboBoxOnSheet()
Worksheets("Sheet1").ComboBox1.Visible = False
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HIS