+ Reply to Thread
Results 1 to 2 of 2

[SOLVED] Checkbox visibility setting fails

  1. #1
    Registered User
    Join Date
    09-19-2011
    Location
    NZ
    MS-Off Ver
    Excel 2003
    Posts
    2

    [SOLVED] Checkbox visibility setting fails

    I am trying to make some dynamically created checkboxes disappear when I hide the row they are in, then reappear when I show the row. The code works for everything except hiding the checkboxes.

    Please Login or Register  to view this content.
    So currently I have ckboxPrintLabels4 thru to 16 on the sheet. They fail to change visibility. Although the msgbox reports that they have visibility at false...???
    Last edited by onyxnz; 09-20-2011 at 12:14 AM. Reason: Solved

  2. #2
    Registered User
    Join Date
    09-19-2011
    Location
    NZ
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Checkbox visibility setting fails

    [SOLVED] Problem in the creation, resulting in duplicates of checkboxes stacking on top of each other
    New code:

    Public Sub addcheckboxes(ByVal Lower As String, ByVal Upper As String)
    Dim ws As Worksheet, myObjectname As String, addChk As Boolean

    Set ws = Workbooks("nursery.xls").Worksheets("Seeding")
    Application.ScreenUpdating = False

    ckbox = Lower
    ' add a checkbox for printing
    For Each cell In ws.Range("g" & Lower & ":g" & Upper)

    myObjectname = "ckboxPrintLabels" & ckbox
    addChk = True

    For Each ctrl In ActiveSheet.CheckBoxes
    ' nasty hack to overcome the limitations of vba in excel - no eval!
    If ctrl.name = myObjectname Then
    addChk = False ' if chkbox already exists
    ctrl.Visible = True 'switch to visible, as it may not be
    End If
    Next

    If addChk Then
    With ws.CheckBoxes.Add(cell.Left, _
    cell.Top, cell.Width, cell.Height)
    .LinkedCell = cell
    .Interior.ColorIndex = xlNone
    .Caption = ""
    .name = myObjectname
    .Visible = True
    End With
    End If
    ckbox = ckbox + 1
    Next
    Application.ScreenUpdating = True
    End Sub

+ 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