+ Reply to Thread
Results 1 to 4 of 4

Converting String to Control Name

Hybrid View

  1. #1
    Registered User
    Join Date
    10-10-2013
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2010
    Posts
    50

    Converting String to Control Name

    I've got a control name written to an array as a string. Example:

    mArr(25, 7)="ComboBoxD44"
    Of course this is a combo box in cell d44.

    What I'm trying to do is to reference this control and make changes (enable other controls, etc) based on its value if set to Yes, but if No or blank, disable controls and skip over processing any of the controls in the group.

    How can I reference this as a control and not a string, so I can test its value such as :

    if ComboBoxD44.Text="Yes" then...
    Last edited by steven_b46; 11-07-2014 at 04:56 PM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Converting String to Control Name

    On a userform, syntax like
    Userform1.Controls("comboBox1").ListIndex = 2
    is used. My Mac doesn't support ActiveX controls for the worksheet, but similar syntax probably exists.
    If you are using controls from the Forms Menu, syntax like
    ActiveSheet.Shapes("Drop Down 1").ControlFormat.ListIndex = 2
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    10-10-2013
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Converting String to Control Name

    I get an error 438: Object doesn't support the property or method. This is the line that has the problem"

    MsgBox ActiveSheet.Controls(mArr(f, 7)).Text
    fyi, mArr(f,7) equals "ComboBoxD44"

    WDYT?
    Last edited by steven_b46; 11-07-2014 at 06:44 PM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Converting String to Control Name

    A worksheet doesn't have a Controls collection.

    msgbox activesheet.oleobjects(mArr(f, 7)).object.text
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Logical Thinking
    By pike in forum The Water Cooler
    Replies: 16
    Last Post: 05-27-2012, 06:54 PM
  2. Help in Thinking Through Process
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-03-2012, 09:27 AM
  3. Over-thinking, to set up info
    By Befuddled2011 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-07-2011, 12:18 AM
  4. One to get you thinking.
    By Ross in forum Excel General
    Replies: 6
    Last Post: 07-13-2006, 09:25 PM
  5. Critical thinking puzzle
    By jazbath in forum Excel General
    Replies: 8
    Last Post: 12-12-2005, 04:10 PM

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