+ Reply to Thread
Results 1 to 5 of 5

Can ALL option buttons within a frame be tied together for common THEN

  1. #1
    Registered User
    Join Date
    11-08-2011
    Location
    bergen county, NJ
    MS-Off Ver
    Excel 2007
    Posts
    72

    Can ALL option buttons within a frame be tied together for common THEN

    Hello again...
    I have multiple frames, each with 9 option buttons. I have my userform coded such that only the relevant frames are highlighted via red coloring to signal the user which frames need input...

    I am trying to code it that whenever any of the 9 button within the frame is selected the coloring changes for that frame only... do i need to create a sub routine for each option buttons' click event, or is there a way i can loop an IF statement for all them ?

    This will be the same exact code "if s1_opt(*).value = true" for all 9 . Is this doable ?

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    11-08-2011
    Location
    bergen county, NJ
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Can ALL option buttons within a frame be tied together for common THEN

    i am reading up on control arrays... sounds like excel 2003 doesn't have this ?

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,750

    Re: Can ALL option buttons within a frame be tied together for common THEN

    The standard way to do this is to add code to each Click event handler for each button. There's no way around it. If there is an action that you want to take when any of the buttons are clicked, then you have to detect a click event for all of the buttons.

    There is another more sophisticated way to do that with classes. You have to create a Class module that defines an option button and will handle a Click event for any option button that is allocated to the class. It's a little tricky for someone new at VBA. This technique is described by John Walkenbach in Excel 2003 Power Programming With VBA and is shown here.

    I'm not sure what you mean by a control array. Do you mean an array of type Control? I don't know what you're reading but the language is the same in 2003 and forward. Some things have changed in the object model, like toolbars go away in 2007 with the introduction of the ribbon, but arrays, data types. control structures are all the same.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Can ALL option buttons within a frame be tied together for common THEN

    Please Login or Register  to view this content.
    Or you can use a class to handle (Withevents) the click events of all optionbuttons.
    Last edited by snb; 11-13-2011 at 05:21 PM.



  5. #5
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Can ALL option buttons within a frame be tied together for common THEN

    Quote Originally Posted by teacher_rob View Post
    i am reading up on control arrays... sounds like excel 2003 doesn't have this ?
    Control arrays are not supported in VBA at all, no. But VB6, yes.
    Hope that helps,

    Colin

    RAD Excel Blog

+ 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