update:
Sub addcheckboxes()
Dim ws, myArry, cll, i
For Each ws In ActiveWorkbook.Worksheets
If ws.Index > 3 Then
'ws.Activate 'not needed
With ws
.Range("N1").Value = "Groupes"
myArry = Array("GR A", "GR B", "GR C", "GR D", "GR E", "GR F", "GR G")
For Each cll In .Range("N2:N8")
With .CheckBoxes.Add(Left:=cll.Left, Top:=cll.Top, Width:=cll.Width, Height:=Range("A1").Height) 'height dependent on cell A1 and not row of checkbox?!
.Caption = myArry(i)
End With
i = i + 1
Next cll
End With
End If
Next ws
End Sub
Sub CheckboxLoop()
Dim LR As Long, i As Long, ws, mytxt
Dim cb As Shape
For Each ws In ActiveWorkbook.Worksheets
If ws.Index > 3 Then
'ws.Activate 'not needed
With ws
Application.ScreenUpdating = False 'could move this line to above: For each ws in…
LR = .Columns("E").Find("*", , xlFormulas, xlPart, , xlPrevious, , , False).Row 'if rows are hidden .End(xlup) won't find them
.Range("1:" & LR).EntireRow.Hidden = False
'Loop through Checkboxes
For Each cb In .Shapes
If cb.Type = msoFormControl Then
If cb.FormControlType = xlCheckBox Then
If cb.ControlFormat.Value = xlOff Then
'Do something if not checked...
mytxt = cb.OLEFormat.Object.Text
For i = 9 To LR 'bear in mind your checkboxes are on the first 9 rows so keep them visible all the time?
If .Range("E" & i).Value = mytxt Then .Rows(i).Hidden = True
Next i
End If
End If
End If
Next cb
End With
End If
Next ws
Application.ScreenUpdating = True
End Sub
Since you're using the .checkboxes to add the checkboxes why don't you use the same for checking them?:
Sub CheckboxLoop2()
Dim LR As Long, i As Long, cb, mytxt, ws
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
If ws.Index > 3 Then
'ws.Activate 'not needed
With ws
LR = .Columns("E").Find("*", , xlFormulas, xlPart, , xlPrevious, , , False).Row 'if rows are hidden .End(xlup) won't find them
.Range("1:" & LR).EntireRow.Hidden = False
'Loop through Checkboxes
For Each cb In .CheckBoxes
If cb.Value <> 1 Then
'Do something if not checked...
mytxt = cb.Caption
For i = 9 To LR 'bear in mind your checkboxes are on the first 9 rows so keep them visible all the time?
If .Range("E" & i).Value = mytxt Then .Rows(i).Hidden = True
Next i
End If
Next cb
End With
End If
Next ws
Application.ScreenUpdating = True
End Sub
re: "lastRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row"
use the same technique I used in the macros above.