+ Reply to Thread
Results 1 to 3 of 3

How to use a String to reference to a CheckBox object?

  1. #1
    Registered User
    Join Date
    05-28-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    19

    How to use a String to reference to a CheckBox object?

    Hi,

    I have created ActiveX checkboxes named chkbx1 and chkbx2. I am running a loop and I need to refer to these objects. I am not sure what is wrong with my code:

    for i=1 to 2
    if "chkbx" & i & .Object.Value = True then
    'Do something
    End If

    next i
    Last edited by excelnewbie80; 06-18-2012 at 03:57 AM.

  2. #2
    Registered User
    Join Date
    06-11-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    86

    Re: How to use a String to reference to a CheckBox object?

    Dear ,

    all the controls on the sheets are referred as Shape

    try the below code

    Sub hhgg()
    Dim x As Shapes
    Dim y As Long
    Dim z As Long
    Dim str As String
    Set x = Application.Sheets(1).Shapes
    y = x.Count
    For z = 1 To y

    str = str & Chr(13) & " " & x(z).Name

    Next z
    MsgBox str
    End Sub


    Instead of Using ActiveX Use normal controls Because u can attach them to any any cell value.

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: How to use a String to reference to a CheckBox object?

    Like this:

    Please Login or Register  to view this content.
    Although if you use forms controls, you can use:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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