Checkbox doesnt show checkmark when it should

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,668
Office Version
  1. 2007
Platform
  1. Windows
Ive confused myself & now not sure whats happening.
Can you advise please.

On my worksheet i have cell G13 where it will either be empty or have a customers name present.

I also have 3 checkboxes.

Basically if i select a customer in cell G13 one of the checkboxes should be checked.
If cell G13 has no name present then the 3 checkboxes should not be seen.

So today i have selected a customer in cell G13 & i see that checkbox3 has the checkmark.
I save the file & come back to it later on, now i see no checkmark at all in any 3 checkboxes.

Looking through all my code for the checkboxes i have found the following & this is where ive confused myself.
Just asking if you see the error which is causing this, Many Thanks


VBA Code:
Private Sub Workbook_Open()
Application.EnableEvents = False

With Sheets("INV")
    If Range("G13").Value = "" Then
        .CheckBox1 = False
        .CheckBox2 = False
        .CheckBox3 = False
        .Range("G21:G23").Value = ""
        .Range("G21").Interior.ColorIndex = 2
        .Range("G21:G23").Borders.LineStyle = xlNone
    End If
End With

Application.EnableEvents = True
    Range("G13:G18,G27:G36,G46:G50").HorizontalAlignment = xlCenter
    Range("G13:G18,G27:G36,G46:G50").VerticalAlignment = xlCenter
End Sub



Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.count > 1 Or Target.HasFormula Then Exit Sub
    If Not Intersect(Target, Range("L14:L18,G13:G18,G45:G48")) Is Nothing Then
        Application.EnableEvents = False
        Target = UCase(Target)
        Application.EnableEvents = True
    End If
    If Not Intersect(Target, Range("G13")) Is Nothing Then
        Range("G27").Select
    End If
    
    If Range("G13").Value = 0 Then
       CheckBox1.Visible = False
       CheckBox2.Visible = False
       CheckBox3.Visible = False
    End If
    If Range("G13").Value > 1 Then
       CheckBox1.Visible = True
       CheckBox2.Visible = True
       CheckBox3.Visible = True
    End If
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
VBA Code:
Private Sub Workbook_Open()
    Application.EnableEvents = False

    With Sheets("INV")
        If .Range("G13").Value = "" Then
            .CheckBox1.Visible = False
            .CheckBox2.Visible = False
            .CheckBox3.Visible = False
            .CheckBox1.Value = False
            .CheckBox2.Value = False
            .CheckBox3.Value = False
            .Range("G21:G23").Value = ""
            .Range("G21").Interior.ColorIndex = 2
            .Range("G21:G23").Borders.LineStyle = xlNone
        Else
            .CheckBox1.Visible = True
            .CheckBox2.Visible = True
            .CheckBox3.Visible = True
            .CheckBox3.Value = True
        End If
    End With

    Application.EnableEvents = True

    With Sheets("INV")
        .Range("G13:G18,G27:G36,G46:G50").HorizontalAlignment = xlCenter
        .Range("G13:G18,G27:G36,G46:G50").VerticalAlignment = xlCenter
    End With
End Sub

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
   
    If Not Intersect(Target, Range("L14:L18,G13:G18,G45:G48")) Is Nothing Then
        Application.EnableEvents = False
        Target.Value = UCase(Target.Value)
        Application.EnableEvents = True
    End If

    If Not Intersect(Target, Range("G13")) Is Nothing Then
        Application.EnableEvents = False
        If Range("G13").Value = "" Then
            CheckBox1.Visible = False
            CheckBox2.Visible = False
            CheckBox3.Visible = False
            CheckBox1.Value = False
            CheckBox2.Value = False
            CheckBox3.Value = False
        Else
            CheckBox1.Visible = True
            CheckBox2.Visible = True
            CheckBox3.Visible = True
            CheckBox3.Value = True
        End If
        Application.EnableEvents = True
        Range("G27").Select
    End If
End Sub
 
Upvote 0
Hi,
I see if both codes above you wrote this one line,can you explain please.

VBA Code:
CheckBox3.Value = True
 
Upvote 0

Forum statistics

Threads
1,222,903
Messages
6,168,939
Members
452,227
Latest member
sam1121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top