Results 1 to 5 of 5

Reference Option Button name in a variable in IF Statement

Threaded View

  1. #1
    Registered User
    Join Date
    03-04-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    3

    Reference Option Button name in a variable in IF Statement

    I'm having trouble figuring out how to reference the name of an option button that I'm storing in a string variable so I can check all the option buttons on my sheet with an IF statement in a loop. I'm populating variable 'strOptionName' from an array at the beginning of each loop iteration and performing the following IF statement where "pre01y" is the name of the option button:

    If Sheets("Sheet1").pre01y = True Then
    The above runs fine and if the "pre01y" option button is selected (true) then the code drops into my IF statement. However, if I am populating a variable name such as "strOptionName" with the same value (option name) it does not work like this:

    If Sheets("Sheet1").strOptionName = True Then
    I get an Object doesn't support property or method error using the option button name in a variable. I have tried doing concatenation, brackets, etc. without any luck. Is it possible to do this and if so how?
    Last edited by diane.perry; 03-04-2014 at 08:25 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 08-15-2013, 12:25 PM
  2. [SOLVED] Call Form Control Option Button within an If statement
    By SonOfOdin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-03-2012, 02:23 PM
  3. Userform Option Button to Show/Hide Another Option Button on same Userform
    By R_S_6 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2010, 09:44 AM
  4. Replies: 2
    Last Post: 03-27-2007, 08:30 AM
  5. Replies: 0
    Last Post: 02-20-2006, 06:00 PM

Tags for this Thread

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