Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm working on a matrix where you can compare products and their options to one another. I've created a macro linked to a data table in my workbook (titled portables). When you click the check boxes for the options it will include the data from Portables workbook and put it in the matrix workbook. You can click each check box to include the option; however some of the options are included in the product. I'm looking for a way that when you click the product check box, it will automatically check the boxes that are included in that product. Below is the VBA code I used.

Sub AddCheckBoxes()
    On Error Resume Next
    Dim c As Range, myRange As Range
    Set myRange = Selection
    For Each c In myRange.Cells
        ActiveSheet.CheckBoxes.Add(c.Left, c.Top, c.Width, c.Height).Select
            With Selection
                .LinkedCell = c.Address
                .Characters.Text = ""
                .Name = c.Address
            End With
            c.Select
            With Selection
                .FormatConditions.Delete
                .FormatConditions.Add Type:=xlExpression, _
                    Formula1:="=" & c.Address & "=TRUE"
                .FormatConditions(1).Font.ColorIndex = 2 'change font color to white when checked
                .FormatConditions(1).Interior.ColorIndex = 2 'change backgrounf color to white when checked
                .Font.ColorIndex = 2 'change font color to white when unchecked
                .Interior.ColorIndex = 2 'change background color to white when unchecked
            End With
        Next
        myRange.Select
End Sub

I'll be grateful for any help.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.