Consulting

Results 1 to 10 of 10

Thread: Help With a Simple Code Please!

  1. #1
    VBAX Regular
    Joined
    Aug 2011
    Posts
    19
    Location

    Arrow Help With a Simple Code Please!

    [vba]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[/vba]

    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

    test.xlsm
    Last edited by lovett10; 08-23-2011 at 12:59 AM.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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[/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Aug 2011
    Posts
    19
    Location
    Its not working it says sub or function not defined and highlights OLEObjects

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Post the workbook please.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Regular
    Joined
    Aug 2011
    Posts
    19
    Location
    Quote Originally Posted by xld
    Post the workbook please.
    uploaded

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Where?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Regular
    Joined
    Aug 2011
    Posts
    19
    Location
    Quote Originally Posted by xld
    Where?
    in the question at the end

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    VBAX Regular
    Joined
    Aug 2011
    Posts
    19
    Location
    Quote Originally Posted by xld
    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

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •