+ Reply to Thread
Results 1 to 2 of 2

Need help with Form Control Check Boxes Please

Hybrid View

  1. #1
    Registered User
    Join Date
    09-06-2012
    Location
    Fresno, CA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Question Need help with Form Control Check Boxes Please

    I know that check boxes are not really associated with any kind of cell, they are freestanding, but I was hoping someone may have an idea to see if they can appear if there is a number in a certain row.

    For example, if there are dollar amounts in Column J, but not in every row, a checkbox will appear in column K only on the rows that have dollar amounts in row J.
    My thought was to just have a checkbox in every row, and see if they can be hidden when there is no data in column J and have them appear when there is data, but not sure how to do.
    Sorry to bug you with this question but I am working on a form for my firm and they these checkboxes to appear automatically only on rows with data.

    Thank you!

    Cole

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Need help with Form Control Check Boxes Please

    TEST ON A SAMPLE OR COPY OF YOUR WORKBOOK

    I would add the checkboxes like this for the range I needed them. And make the the checkbox name = "Check box " & the row its in.
    Sub test()
     Dim cb As CheckBox
     For ptr = 2 To 10
        Set rng = Cells(ptr, "k")
        Set cb = CheckBoxes.Add(rng.Left, rng.Top, rng.Width, rng.Height)
        With cb
            .Caption = "hello world"
            .Name = "Check box " & ptr
            '.OnAction = "Macro"
            '.Visible = False
        End With
     Next
    End Sub
    Then you could hide and unhide them by name. I dnt know the full scope of your project so this is just an idea.

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Range("j2:j10"), Target) Is Nothing Then
            If Target.Value > "" Then
                Shapes("Check box " & Target.Row).Visible = msoCTrue
            Else
                Shapes("Check box " & Target.Row).Visible = msoFalse
            End If
        End If
        Set rng = Nothing
    End Sub
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

+ 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