PDA

View Full Version : Help With a Simple Code Please!



lovett10
08-23-2011, 12:17 AM
Dim cbo As OLEObject
Dim ws As Worksheet
Set ws = Worksheets("Boiler")
If OLEObjects("ComboBox1").Object.Value = "Boiler4" Then
Set OLEObjects("CheckBox2").Object.Value = True
Else
Set OLEObjects("CheckBox2").Object.Value = False
End If

Can you tell me whats wrong and how to fix it please, i am trying to make it so that when ComboBox1 says "Boiler4" the checkbox autommatically ticks itself.

thanks in advance

6455

Bob Phillips
08-23-2011, 12:29 AM
Dim cbo As OLEObject
Dim ws As Worksheet
Set ws = Worksheets("Boiler")
If OLEObjects("ComboBox1").Object.Value = "Boiler4" Then
OLEObjects("CheckBox2").Object.Value = True
Else
OLEObjects("CheckBox2").Object.Value = False
End If

lovett10
08-23-2011, 12:30 AM
Its not working it says sub or function not defined and highlights OLEObjects

Bob Phillips
08-23-2011, 12:56 AM
Post the workbook please.

lovett10
08-23-2011, 12:59 AM
Post the workbook please.

uploaded

Bob Phillips
08-23-2011, 01:02 AM
Where?

lovett10
08-23-2011, 01:03 AM
Where?

in the question at the end

Bob Phillips
08-23-2011, 01:09 AM
Didn't expect it up there!

That code wasn't in the workbook, but add item worked fine. If I added that code to the combobox change event, that worked fine too. I can't see any problems.

lovett10
08-23-2011, 01:24 AM
Didn't expect it up there!

That code wasn't in the workbook, but add item worked fine. If I added that code to the combobox change event, that worked fine too. I can't see any problems.

ok thanks i was putting it into a module rather that the combobox code... Derp :P thanks again for the help

Bob Phillips
08-23-2011, 01:36 AM
That shouldn't stop it working, it would just mean that you have to trigger the code rather than be automatically triggered when the selection in the comboox is made.