Sub Selection_cellules_verrouillees()
Dim ur As Range, zone1 As Range, zone2 As Range, zone3 As Range, zone4 As Range, zone5 As Range, c As Range, ref As Range
Set ur = ActiveSheet.UsedRange
If ur.Row > 1 Then If ur(0, 1).Locked Then Set zone1 = Rows("1:" & ur.Row - 1)
If ur.Row + ur.Rows.Count - 1 < Rows.Count Then If ur(ur.Rows.Count + 1, 1).Locked Then Set zone2 = Rows(ur.Row + ur.Rows.Count & ":" & Rows.Count)
If ur.Column > 1 Then If ur(1, 0).Locked Then Set zone3 = Columns(1).Resize(, ur.Column - 1)
If ur.Column + ur.Columns.Count - 1 < Columns.Count Then If ur(1, ur.Columns.Count + 1).Locked Then _
Set zone4 = Columns(ur.Column + ur.Columns.Count).Resize(, Columns.Count - ur.Column - ur.Columns.Count + 1)
For Each c In ur
If c.Locked Then Set zone5 = Union(IIf(zone5 Is Nothing, c, zone5), c)
Next
If Not zone1 Is Nothing Then Set ref = zone1
If Not zone2 Is Nothing Then Set ref = zone2
If Not zone3 Is Nothing Then Set ref = zone3
If Not zone4 Is Nothing Then Set ref = zone4
If Not zone5 Is Nothing Then Set ref = zone5
If ref Is Nothing Then MsgBox "Aucune cellule verrouillée" Else _
Union(IIf(zone1 Is Nothing, ref, zone1), IIf(zone2 Is Nothing, ref, zone2), IIf(zone3 Is Nothing, ref, zone3), IIf(zone4 Is Nothing, ref, zone4), IIf(zone5 Is Nothing, ref, zone5)).Select
End Sub
Sub Selection_cellules_deverrouillees()
Dim ur As Range, zone1 As Range, zone2 As Range, zone3 As Range, zone4 As Range, zone5 As Range, c As Range, ref As Range
Set ur = ActiveSheet.UsedRange
If ur.Row > 1 Then If Not ur(0, 1).Locked Then Set zone1 = Rows("1:" & ur.Row - 1)
If ur.Row + ur.Rows.Count - 1 < Rows.Count Then If Not ur(ur.Rows.Count + 1, 1).Locked Then Set zone2 = Rows(ur.Row + ur.Rows.Count & ":" & Rows.Count)
If ur.Column > 1 Then If Not ur(1, 0).Locked Then Set zone3 = Columns(1).Resize(, ur.Column - 1)
If ur.Column + ur.Columns.Count - 1 < Columns.Count Then If Not ur(1, ur.Columns.Count + 1).Locked Then _
Set zone4 = Columns(ur.Column + ur.Columns.Count).Resize(, Columns.Count - ur.Column - ur.Columns.Count + 1)
For Each c In ur
If Not c.Locked Then Set zone5 = Union(IIf(zone5 Is Nothing, c, zone5), c)
Next
If Not zone1 Is Nothing Then Set ref = zone1
If Not zone2 Is Nothing Then Set ref = zone2
If Not zone3 Is Nothing Then Set ref = zone3
If Not zone4 Is Nothing Then Set ref = zone4
If Not zone5 Is Nothing Then Set ref = zone5
If ref Is Nothing Then MsgBox "Aucune cellule déverrouillée" Else _
Union(IIf(zone1 Is Nothing, ref, zone1), IIf(zone2 Is Nothing, ref, zone2), IIf(zone3 Is Nothing, ref, zone3), IIf(zone4 Is Nothing, ref, zone4), IIf(zone5 Is Nothing, ref, zone5)).Select
End Sub