+ Reply to Thread
Results 1 to 4 of 4

Disable Object buttons, based on value of other object buttons

Hybrid View

Guest Disable Object buttons, based... 06-01-2006, 04:15 PM
Leith Ross Hello Jeffbert, I am... 06-01-2006, 10:49 PM
Guest Re: Disable Object buttons,... 06-02-2006, 11:45 AM
Guest Re: Disable Object buttons,... 06-02-2006, 11:40 AM
  1. #1
    jeffbert
    Guest

    Disable Object buttons, based on value of other object buttons

    I have two groups of object buttons. The first group is Object 7 and Object
    button 10. The second group is Object button 8 and Object button 9. What I
    want to do is if Object button 7 is = TRUE, allow the user to be able to
    select values in object buttons 8 and 9. If Object button 10 = TRUE, then
    they cannot select options in 8 and 9.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Jeffbert,

    I am guessing your Object Buttons are Forms Option Buttons. If that is the case then the following macro should give you the results you want.

    First copy this code to the clipboard using Ctrl + C. Second add a standard VBA Module to your Workbook and paste the code into it. Right Click each Option Button and assign this macro to it.

    Adding a Module:
    1) Open your Workbook and press Alt + F11 to launch the VBA Editor.
    2) Press Alt + I to drop down the Insert Menu.
    3) Press M to add the Module to the Workbook.
    4) Press Ctrl + V to paste the macro code into it.
    5) Press Ctrl + S to Save the changes.
    6) Press Alt + Q to Quit the VBA Editor and return to Excel

    Macro Code:
    Public Sub ControlOptions()
    
      Dim ID
      Dim OptBtn As Shape
      
        ID = Application.Caller
        Set OptBtn = ActiveSheet.Shapes(ID)
        
        With ActiveSheet.Shapes
          Select Case OptBtn.Name
            Case Is = "Option Button 7"
              .Item("Option Button 8").ControlFormat.Enabled = True
              .Item("Option Button 9").ControlFormat.Enabled = True
            Case Is = "Option Button 10"
              .Item("Option Button 8").ControlFormat.Enabled = False
              .Item("Option Button 9").ControlFormat.Enabled = False
           End Select
        End With
        
    End Sub
    Sincerely,
    Leith Ross

  3. #3
    jeffbert
    Guest

    Re: Disable Object buttons, based on value of other object buttons

    Leith

    Thank you for the response. However, I am using the option buttons from the
    active x toolbar, and not the forms toolbar. When I try to run the macro, I
    am getting the following error: Run time error '13': Type Mismatch and the
    debugger highlights this line of code "Set OptBtn = ActiveSheet.Shapes(ID)"

    Thanks again

    Jeff


    "Leith Ross" wrote:

    >
    > Hello Jeffbert,
    >
    > I am guessing your Object Buttons are Forms Option Buttons. If that is
    > the case then the following macro should give you the results you
    > want.
    >
    > First copy this code to the clipboard using Ctrl + C. Second add a
    > standard VBA Module to your Workbook and paste the code into it. Right
    > Click each Option Button and assign this macro to it.
    >
    > Adding a Module:
    > 1) Open your Workbook and press Alt + F11 to launch the VBA Editor.
    > 2) Press Alt + I to drop down the Insert Menu.
    > 3) Press M to add the Module to the Workbook.
    > 4) Press Ctrl + V to paste the macro code into it.
    > 5) Press Ctrl + S to Save the changes.
    > 6) Press Alt + Q to Quit the VBA Editor and return to Excel
    >
    > Macro Code:
    >
    > Code:
    > --------------------
    >
    > Public Sub ControlOptions()
    >
    > Dim ID
    > Dim OptBtn As Shape
    >
    > ID = Application.Caller
    > Set OptBtn = ActiveSheet.Shapes(ID)
    >
    > With ActiveSheet.Shapes
    > Select Case OptBtn.Name
    > Case Is = "Option Button 7"
    > .Item("Option Button 8").ControlFormat.Enabled = True
    > .Item("Option Button 9").ControlFormat.Enabled = True
    > Case Is = "Option Button 10"
    > .Item("Option Button 8").ControlFormat.Enabled = False
    > .Item("Option Button 9").ControlFormat.Enabled = False
    > End Select
    > End With
    >
    > End Sub
    >
    > --------------------
    >
    >
    > Sincerely,
    > Leith Ross
    >
    >
    > --
    > Leith Ross
    > ------------------------------------------------------------------------
    > Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
    > View this thread: http://www.excelforum.com/showthread...hreadid=547617
    >
    >


  4. #4
    jeffbert
    Guest

    Re: Disable Object buttons, based on value of other object buttons

    Leith

    Thank you for the response. However, I am using the option buttons from the
    active x toolbar, and not the forms toolbar. When I try to run the macro, I
    am getting the following error: Run time error '13': Type Mismatch and the
    debugger highlights this line of code "Set OptBtn = ActiveSheet.Shapes(ID)"

    Thanks again

    Jeff


    "Leith Ross" wrote:

    >
    > Hello Jeffbert,
    >
    > I am guessing your Object Buttons are Forms Option Buttons. If that is
    > the case then the following macro should give you the results you
    > want.
    >
    > First copy this code to the clipboard using Ctrl + C. Second add a
    > standard VBA Module to your Workbook and paste the code into it. Right
    > Click each Option Button and assign this macro to it.
    >
    > Adding a Module:
    > 1) Open your Workbook and press Alt + F11 to launch the VBA Editor.
    > 2) Press Alt + I to drop down the Insert Menu.
    > 3) Press M to add the Module to the Workbook.
    > 4) Press Ctrl + V to paste the macro code into it.
    > 5) Press Ctrl + S to Save the changes.
    > 6) Press Alt + Q to Quit the VBA Editor and return to Excel
    >
    > Macro Code:
    >
    > Code:
    > --------------------
    >
    > Public Sub ControlOptions()
    >
    > Dim ID
    > Dim OptBtn As Shape
    >
    > ID = Application.Caller
    > Set OptBtn = ActiveSheet.Shapes(ID)
    >
    > With ActiveSheet.Shapes
    > Select Case OptBtn.Name
    > Case Is = "Option Button 7"
    > .Item("Option Button 8").ControlFormat.Enabled = True
    > .Item("Option Button 9").ControlFormat.Enabled = True
    > Case Is = "Option Button 10"
    > .Item("Option Button 8").ControlFormat.Enabled = False
    > .Item("Option Button 9").ControlFormat.Enabled = False
    > End Select
    > End With
    >
    > End Sub
    >
    > --------------------
    >
    >
    > Sincerely,
    > Leith Ross
    >
    >
    > --
    > Leith Ross
    > ------------------------------------------------------------------------
    > Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
    > View this thread: http://www.excelforum.com/showthread...hreadid=547617
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1