View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default If then to hide a combo box

Do you know how to put break points into the code in VBA. there are two
possible reasons for problems

1) The code isn't being called. Put breakpoint in VBA code by putting
cursor on the line and pressing F9. the usual reason for this is the code
was put on the wrong module. there are different modules that are associated
with different worksheets in excel. Go to excel and right click the
worksheet tabe on the bottom of the worksheet. select view code. Put the
code on this worksheet


2) the form or combobox has a different number than the one you are calling.
right click the form and combox and select properties. The first line is
the alphabetize property box is a name. This is the name you should use when
call the form or combobox. I usually change these names to things like
Plantscombox, TreeCombobox or whatever type data you are putting into these
boxes. Otherwise, if you have multiple boxes or forms you end up referencing
the wrong items. Usually problems occur when you delete items excel skips
these numbers. You probably have combobox2 instead of combobox1.

"TDC" wrote:

Joel,

Thanks for the help, but I still not able to make it work. I even tried a
blank workbook and worksheet, but no change. Any idea what I am missing?

"Joel" wrote:

I got the code to work. I only added a workseet reference.


Sub test_form()
If Worksheets("main").Range("AJ19").Value 1 Then
UserForm1.ComboBox1.Visible = True
Else
UserForm1.ComboBox1.Visible = False
End If
UserForm1.Show

End Sub




"TDC" wrote:

I am trying to make a combo box appear if a value is greater than 1 or hide
if it is not. Below is what I have, but it does not work. Suggestions?

Private Sub test_change()
If Range("AJ19").Value 1 Then
UserForm1.ComboBox1.Visible = True
Else
UserForm1.ComboBox1.Visible = False
End If
End Sub