Matt Taylor
Matt Taylor

Reputation: 671

Trying to only type check boxes in specific cells

I want to avoid the Developer checkboxes so I found this code, but need multiple columns to be check boxes. Specifically columns 4,5,6.

I know its simple. Here is what I am working with

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    With Target
    'Column D
        If .Column <> 4 Then Exit Sub
        On Error Resume Next
        If Asc(.Value) = 168 Then
            .Font.Name = "Wingdings"
            .Value = Chr(254)
        Else: .Value = Chr(168)
        End If
    End With
End Sub

Thanks

Upvotes: 0

Views: 31

Answers (1)

Gary&#39;s Student
Gary&#39;s Student

Reputation: 96753

Just test columns D, E, F:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    With Target
    'Column D & E & F
        If .Column = 4 Or .Column = 5 Or .Column = 6 Then
            On Error Resume Next
            If Asc(.Value) = 168 Then
                .Font.Name = "Wingdings"
                .Value = Chr(254)
            Else
                .Value = Chr(168)
            End If
        End If
    End With
End Sub

Upvotes: 1

Related Questions