1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim Obj As Shape, Ligne As Long
Dim LaDate As Date, J As Long
' Première partie
Ligne = Selection.Row
If Range("B" & Ligne) = "" Or Ligne > Range("A" & Rows.Count).End(xlUp).Row Or Ligne < 5 Then
Ligne = Range("A" & Rows.Count).End(xlUp).Row
End If
If UCase(Sh.Name) <> "MENU" And Target.Count = 1 And Target.Column = 2 And Target.Row > 5 Then
Application.ScreenUpdating = False
For Each Obj In ActiveSheet.Shapes
If InStr(1, Obj.TextFrame.Characters.Text, "Centrer Texte", vbTextCompare) > 0 Then Exit For
Next Obj
If Not Obj Is Nothing Then
With Obj.TextFrame
If Range("B" & Ligne).HorizontalAlignment = xlCenterAcrossSelection Then
.Characters.Text = "Annuler Centrer Texte" & vbLf & "Sur Plusieurs Colonnes"
.Characters(Start:=23, Length:=22).Font.ColorIndex = 5
Else
.Characters.Text = "Centrer Texte" & vbLf & "Sur Plusieurs Colonnes"
.Characters(Start:=15, Length:=22).Font.ColorIndex = 5
End If
End With
End If
End If
' Deuxième partie
If Target.Column = 2 Then
Application.ScreenUpdating = False
For J = 6 To 36
If Cells(J, "B") = "" Then Cells(J, "A").ClearContents
Next J
LaDate = DateSerial(Split(Sh.Name, " ")(1), Month(DateValue(Sh.Name)), Target.Row - 5)
If UCase(MonthName(Month(LaDate))) = UCase(Split(Sh.Name, " ")(0)) Then
' Si les colonnes B et C sont vides, on efface la date
Range("A" & Target.Row) = Application.Proper(Format(LaDate, "dddd dd mmmm yyyy"))
End If
End If
Application.ScreenUpdating = True
End Sub |
Partager