+ Reply to Thread
Results 1 to 5 of 5

Set an Option Button by Name

  1. #1
    Registered User
    Join Date
    10-08-2004
    Posts
    3

    Set an Option Button by Name

    Hi

    In Excel 2003 VBA, what is the syntax for controling an Option Button or Checkbox by name or caption

    I have tried the following but has an error, I am sure this is a simple one...

    Please Login or Register  to view this content.
    Re Dave
    Last edited by Dave Taylor; 10-08-2009 at 05:26 PM. Reason: Add application name

  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

    Re: Set an Option Button by Name

    Hello Dave Taylor,

    Welcome to the Forum!

    You were very close to getting it. The Controls object is a Collection object. Collections generally can be indexed either by a number or string. You code should look like this...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    10-08-2004
    Posts
    3

    Re: Set an Option Button by Name

    Hi Leith

    Thanks for that, but that won't do what I need.

    I have 10 check boxes, I want to look at check boxes 2 -10.

    If any of the Check boxes 2 to 10 are checked I want to uncheck "checkbox 1"

    I can test the boxes using the "For Each" but at the end I want to set a particular known box.

    Hope thats clear, I was hoping to find a syntax to address a single item.

    Re Dave

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

    Re: Set an Option Button by Name

    Hello Dave,

    Here is sample loop to test check boxes 2 through 10 and if any are checked then "Checkbox1" is unchecked.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 10-08-2009 at 07:58 PM. Reason: Provided wrong code for the question

  5. #5
    Registered User
    Join Date
    10-08-2004
    Posts
    3

    Re: Set an Option Button by Name

    Sorted

    Many thanks for your help

    Re Dave

+ 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