problem with a combo box in a worksheet
Bernie,
I would love to send you my workbook; however, I can't due to the company's
policy. Please help me without my workbook.
Besides my workbook, I did a test workbook. In the test workbook, I create
a combo box in Sheet1, and in cells $C$1:$C$4 of Sheet1, I type in the
values. The values in cells $C$1:$C$4 of both actual and test workbooks are
values, not formula. Then I have $C$1:$C$4 in ListFillRange and combo box
name cboTest in Name of combo box Properties, and I change nothing else in
the combo box Properties.
In the VBAProject of Sheet1, I have the following code:
private sub cboTest_Click()
application.screenupdating=false
select case cboTest.value
case "Selection1"
msgbox "selection1"
case "selection2"
msgbox "selection2"
case "selection3"
msgbox "selection3"
end select
application.screenupdating=true
end sub
I click on the combo box to change the value, and it works. When I close
the workbook and reopen it, the combo box code executes. For example, when I
open the workbook with "selection3" in my combo box, I would receive a
message "selection3".
Did I miss something? Is there a setting in Excel (e.g. Tools Options)
that I need to check to say do not execute the combo box code when the file
is opened?
Thanks.
"Bernie Deitrick" wrote:
Souny,
I was not able to replicate your problem, with my setup.
Are there formulas in C1:C4 or are they values?
And if you want, you can send the workbook to me privately. Just make the obvious changes to my
email address.
HTH,
Bernie
MS Excel MVP
"Souny" wrote in message
...
Bernie,
Thank you very much for continuing to help.
The values in the combo box are looking up the cells $C$1:$C$4 in Sheet1,
and the cells are referenced in ListFillRange as $C$1:$C$4 in the combo box
Properties. Therefore, the values are not populated from the code.
Do you think I need to add your code as part of my code like the following?
If Range("$C$1:$C$4").Value < "Enabled" Then Exit Sub
Please help. Thanks.
"Bernie Deitrick" wrote:
Does the combobox list range contain formulas rather than values?
At the end of it all, you could change your macro code to look at some other enabling value that
you
store in a named cell somewhere... for example
If Range("DisableCombo").Value < "Enabled" Then Exit Sub
HTH,
Bernie
MS Excel MVP
"Souny" wrote in message
...
Bernie,
Thanks for your response. I tried with Change event, and the problem still
exists.
I don't know why. Please help.
"Bernie Deitrick" wrote:
Souny,
Try using the Change event rather than the click event. The initial recalc seems to be firing
the
click event code, but should not fire the change event.
HTH,
Bernie
MS Excel MVP
"Souny" wrote in message
...
Tom,
Could you help me one thing?
I have a combo box in one of my worksheets, and the code for the combo box
is also in the same worksheet "Sheet1". Basically, the code will execute the
lines based on the value selected (from clicking) from the combo box.
Somehow, the code automatically executes when the file is opened.
I have tried many ways, and I am still having problems. I don't understand
why the code will automatically execute when the file is opened.
Below is my code structure.
Private Sub cboCode_Click()
Application.ScreenUpdating=False
Select Case cboCode.Value
Case "Selection1"
'Do the following
Case "Selection2"
'Do the following
Cash "Selection3"
'Do the following
Case Else
'Do the following
End Select
Application.ScreenUpdating = True
End Sub
Please help.
Thanks.
"Tom Ogilvy" wrote:
I depends on what you think the normal rules are.
right click on the combobox and select properties. in rowsource, the link
for the dropdown list, put something like
Sheet1!A1:A30
in Control source (the link for the result)
sheet2!B9
--
Regards,
Tom Ogilvy
"Andy the yeti" wrote:
Hi,
Due to some superb help from these groups I have almost achieved what I
wanted to do using a userform, I have one last hurdle now that involves using
a combo box on a userform.
Do these follow the rules of normal of combo boxes in regards to a cell link
and input range? If so could I have some pointers please on how to set up the
properties?
Thank you very much
Andy
|