Results 1 to 2 of 2

Excel VBA - Auto adding checkboxes

Threaded View

TheGnome Excel VBA - Auto adding... 06-24-2009, 12:42 PM
Leith Ross Re: Excel VBA - Auto adding... 06-24-2009, 12:56 PM
  1. #1
    Registered User
    Join Date
    06-24-2009
    Location
    San Jose, CA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Excel VBA - Auto adding checkboxes

    Ok so what I'm aiming for here is a form, Which has essentially 3 buttons on top.


    One of these buttons adds a new Row to the form (the row contains all the elements of the previous row and includes a checkbox automatically in the leftmost cell.

    This I have working with the following macro attached to one of the buttons:
    Sub testme()
        Rows("25:25").Select
        Selection.Insert Shift:=xlDown
        Dim myCBX As CheckBox
        Dim myCell As Range
    
        With ActiveSheet
            '.CheckBoxes.Delete 'nice for testing
            For Each myCell In ActiveSheet.Range("A25:A25").Cells
                With myCell
                    Set myCBX = .Parent.CheckBoxes.Add _
                                    (Top:=.Top, Width:=.Width - 35, _
                                    Left:=.Left + 33, Height:=.Height)
                                    
                            
                    With myCBX
                        .LinkedCell = myCell.Address(external:=True)
                        .Caption = ""
                        .Name = "CBX_" & myCell.Address(0, 0)
                    End With
                    .NumberFormat = ";;;"
                End With
    
            Next myCell
        End With
    End Sub
    The part on which I'm stuck is the next button.. Which should hide any row which contains a Check Box that is not currently clicked, and then send the form to the printer. Is there a better way to implement this, and have it be automated as the macro above was?
    Sub Macro1()
    '
    If Cells(23, A).Value = "TRUE" ThenRows("23:23").EntireRow.Hidden = False Else If Cells(23, A).Value = "FALSE" Rows("23:23").EntireRow.Hidden = True
    Last edited by Leith Ross; 06-24-2009 at 12:55 PM. Reason: Code Tags

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