Boostez vos compétences Excel avec notre communauté !
Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !
Sub coloriage(i)
Dim CellDate As Range, LObj As ListObject
Créneau = (ActiveCell.Row - 6) Mod 5
Set CellDate = Application.Intersect(ActiveCell.EntireColumn, Feuil1.Rows(ActiveCell.Row).Offset(-Créneau))
If CellDate Is Nothing Then Exit Sub
Set LObj = Feuil3.ListObjects("Records")
With LObj.ListRows
If .Count = 0 Then .Add
If Not IsEmpty(.Item(.Count).Range.Cells(1)) Then .Add
.Item(.Count).Range.Cells(1).Value = CellDate.Value
.Item(.Count).Range.Cells(2).Value = Créneau
.Item(.Count).Range.Cells(3).Value = i
End With
With Feuil2.[Couleurs].Cells(i)
ActiveCell = .Value
ActiveCell.Interior.Color = .Interior.Color
ActiveCell.Font.Color = .Font.Color
End With
End Sub
Sub EffacerPlanning()
Dim Planning As Range
Set Planning = Feuil1.[Planning]
For Each Zone In Planning.Areas
Zone.ClearContents
Zone.Interior.Color = xlNone
Next Zone
End Sub
Sub ChangementPlanning()
Dim MaCell As Range, Ligne As Long, Créneau As Byte
Dim Tb, TbTâches()
Dim Dc As New Scripting.Dictionary
Dc.CompareMode = vbTextCompare
With Feuil3.ListObjects("Records")
With .Sort
With .SortFields
.Clear
.Add2 Key:=Range("Records[Date]"), SortOn:=xlSortOnValues, Order:=xlAscending
.Add2 Key:=Range("Records[Créneau]"), SortOn:=xlSortOnValues, Order:=xlAscending
End With
.Header = xlYes
.Apply
End With
With .Range
Tb = .Offset(1).Resize(.Rows.Count - 1).Value2
End With
End With
With Feuil2.[Couleurs]
ReDim TbTâches(1 To .Count, 1 To 3)
For i = 1 To .Count
TbTâches(i, 1) = .Cells(i).Value
TbTâches(i, 2) = .Cells(i).Interior.Color
TbTâches(i, 3) = .Cells(i).Font.Color
Next i
End With
Set MaCell = ActiveCell
DMin = Feuil1.[B6].Value2
DMax = Feuil1.[H21].Value2
For i = 1 To UBound(Tb)
If Tb(i, 1) >= DMin And Tb(i, 1) <= DMax Then
OffC = (Tb(i, 1) - DMin) Mod 7
OffL = ((Tb(i, 1) - DMin) \ 7) * 5 + Tb(i, 2)
Dc(OffL & "-" & OffC) = TbTâches(Tb(i, 3), 1) & Chr(9) & TbTâches(Tb(i, 3), 2) & Chr(9) & TbTâches(Tb(i, 3), 3)
End If
Next i
If Dc.Count > 0 Then
Clefs = Dc.Keys: Valeurs = Dc.Items
With Feuil1.[B6]
For i = 0 To Dc.Count - 1
d = Split(Clefs(i), "-")
V = Split(Valeurs(i), Chr(9))
With .Offset(CInt(d(0)), CInt(d(1)))
.Value = V(0): .Interior.Color = V(1): .Font.Color = V(2)
End With
Next
End With
End If
End Sub
Sub MàjPlanning()
Application.EnableEvents = False
Application.ScreenUpdating = False
EffacerPlanning
ChangementPlanning
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Me.[AnnéeCal].Address Or Target.Address = Me.[MoisCal].Address Or Target.Address = Me.[DébutSemaine].Address Then
MàjPlanning
End If
End Sub
Public Temps As Date
Sub ChangeBandeau()
Dim sh As Object
Application.EnableEvents = False
Feuil1.[n°_Image] = ((Feuil1.[n°_Image]) Mod 9) + 1
Set sh = Feuil1.Shapes("Bandeau " & Feuil1.[n°_Image])
sh.ZOrder msoSendToFront
Application.EnableEvents = True
End Sub
Sub ExecuteChangeBandeau()
ChangeBandeau
Temps = Now + TimeValue("00:00:05")
Application.OnTime Temps, "ExecuteChangeBandeau"
End Sub
Sub Arrêt()
Application.OnTime Temps, "ExecuteChangeBandeau", , False
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next: Arrêt: On Error GoTo 0
End Sub
Private Sub Workbook_Open()
ExecuteChangeBandeau
End Sub
Erreur sur le nom de la constante ! c'est msoBringToFront ou plus simplement 0 doncsh.ZOrder msoSendToFront
J'ai mis en référence Microsoft Scripting RunTime pour utiliser un dictionnaire en Early Binding et j'ai oublié de te prévenir !"ERREUR COMPILATION: Projet ou bibliothèque introuvable"
Sub Nom_Shapes()
Dim i As Byte, Sh As Shape
For i = 1 To 9
Set Sh = Feuil1.Shapes("Bandeau " & i)
Sh.ZOrder 0
Application.Wait Now + TimeValue("00:00:01")
MsgBox "Photo Bandeau " & i & " OK"
Next i
End Sub
Public Sub MakeClipIconCouleur(coul As Long, Optional forme = 6)
Dim ico As Object
With ActiveSheet
Set ico = .Shapes.AddShape(forme, 10, 10, 10, 10)
With ico
.DrawingObject.Interior.Color = coul
.Line.Visible = False
.CopyPicture
.Delete
End With
End With
End Sub
Sub AfficherBarreMenu()
Dim X&, A&, Y, Barre As CommandBar, bouton
X = Round(Feuil2.[Couleurs].Cells.Count / 3): A = 1: Y = 0
On Error Resume Next
Set Barre = Application.CommandBars.Add("BarreColoriage" & 1): Barre.Visible = True
For i = 1 To Feuil2.[Couleurs].Cells.Count
Y = Y + 1
If Y = X Then Y = 0: A = A + 1: Set Barre = CommandBars.Add("BarreColoriage" & A): Barre.Visible = True
Set bouton = Barre.Controls.Add(msoControlButton, , , , True)
With bouton
.Caption = Feuil2.[Couleurs].Cells(i)
.Style = msoButtonIconAndCaption
MakeClipIconCouleur Feuil2.[Couleurs].Cells(i).Interior.Color
.PasteFace
.OnAction = "'Coloriage """ & i & """'"
End With
Next
End Sub
Sub EffacerBarreMenu()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
If Cbar.BuiltIn = False Then Cbar.Delete
Next
End Sub
Sub Supprimer()
Dim C As Range, Celldate As Range, Créneau As Byte, Tb, i As Long, TbClef, TbDel
If Intersect(Feuil1.[Planning], Selection).Address = Selection.Address Then
'Tableaux pour la recherche et la suppression dans le Listobject "Records"
Tb = Feuil3.[Records]: nb = UBound(Tb)
ReDim TbClef(1 To nb)
ReDim TbDel(1 To nb)
For i = 1 To nb
TbClef(i) = Tb(i, 1) & "¤" & Tb(i, 2)
TbDel(i) = False
Next
For Each C In Selection.Cells
With C
If Not IsEmpty(C) Then
Créneau = (C.Row - 6) Mod 5
Set Celldate = Application.Intersect(C.EntireColumn, Feuil1.Rows(C.Row).Offset(-Créneau))
'Marquage de la ligne à supprimer du listObject "Records"
idx = -1
On Error Resume Next
idx = WorksheetFunction.Match(Celldate.Value & "¤" & Créneau, TbClef, 0)
TbDel(idx) = True
On Error GoTo 0
End If
'Effacement du contenu et du formatage de la cellule
.ClearContents
.Interior.Color = xlNone
.Font.ColorIndex = xlAutomatic
End With
Next C
'Suppression dans le Listobject "Records"
With Feuil3.[Records].ListObject
For i = nb To 1 Step -1
If TbDel(i) Then .ListRows(i).Delete
Next
End With
End If
End Sub
Sub coloriage(i)
Dim Celldate As Range, LObj As ListObject
Créneau = (ActiveCell.Row - 6) Mod 5
Set Celldate = Application.Intersect(ActiveCell.EntireColumn, Feuil1.Rows(ActiveCell.Row).Offset(-Créneau))
If Celldate Is Nothing Then Exit Sub
Set LObj = Feuil3.ListObjects("Records")
With LObj.ListRows
If .Count = 0 Then .Add
If Not IsEmpty(.Item(.Count).Range.Cells(1)) Then .Add
.Item(.Count).Range.Cells(1).Value = Celldate.Value
.Item(.Count).Range.Cells(2).Value = Créneau
.Item(.Count).Range.Cells(3).Value = i
End With
With Feuil2.[Couleurs].Cells(i)
ActiveCell = .Value
ActiveCell.Interior.Color = .Interior.Color
ActiveCell.Font.Color = .Font.Color
End With
End Sub
Sub EffacerPlanning()
Dim Planning As Range
Set Planning = Feuil1.[Planning]
For Each Zone In Planning.Areas
Zone.ClearContents
Zone.Interior.Color = xlNone
Zone.Font.ColorIndex = xlAutomatic
Next Zone
End Sub
Sub ChangementPlanning()
Dim MaCell As Range, Ligne As Long, Créneau As Byte
Dim Tb, TbTâches()
Dim Dc As Object 'Pour Late Binding sans Microsoft Scripting Runtime en Référence
Set Dc = CreateObject("Scripting.Dictionary")
' Dim Dc As New Scripting.Dictionary 'Pour Early Binding avec Microsoft Scripting Runtime en Référence
Dc.CompareMode = vbTextCompare
With Feuil3.ListObjects("Records")
With .Sort
With .SortFields
.Clear
.Add Key:=Range("Records[Date]"), SortOn:=xlSortOnValues, Order:=xlAscending
.Add Key:=Range("Records[Créneau]"), SortOn:=xlSortOnValues, Order:=xlAscending
End With
.Header = xlYes
.Apply
End With
With .Range
Tb = .Offset(1).Resize(.Rows.Count - 1).Value2
End With
End With
With Feuil2.[Couleurs]
ReDim TbTâches(1 To .Count, 1 To 3)
For i = 1 To .Count
TbTâches(i, 1) = .Cells(i).Value
TbTâches(i, 2) = .Cells(i).Interior.Color
TbTâches(i, 3) = .Cells(i).Font.Color
Next i
End With
Set MaCell = ActiveCell
DMin = Feuil1.[B6].Value2
DMax = Feuil1.[H31].Value2
For i = 1 To UBound(Tb)
If Tb(i, 1) >= DMin And Tb(i, 1) <= DMax Then
OffC = (Tb(i, 1) - DMin) Mod 7
OffL = ((Tb(i, 1) - DMin) \ 7) * 5 + Tb(i, 2)
Dc(OffL & "-" & OffC) = TbTâches(Tb(i, 3), 1) & Chr(9) & TbTâches(Tb(i, 3), 2) & Chr(9) & TbTâches(Tb(i, 3), 3)
End If
Next i
If Dc.Count > 0 Then
Clefs = Dc.Keys: Valeurs = Dc.Items
With Feuil1.[B6]
For i = 0 To Dc.Count - 1
d = Split(Clefs(i), "-")
V = Split(Valeurs(i), Chr(9))
With .Offset(CInt(d(0)), CInt(d(1)))
.Value = V(0): .Interior.Color = V(1): .Font.Color = V(2)
End With
Next
End With
End If
End Sub
Sub MàjPlanning()
Application.EnableEvents = False
Application.ScreenUpdating = False
EffacerPlanning
ChangementPlanning
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Public Temps As Date
Sub ChangeBandeau()
'Passage de la photo suivante au premier plan
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Dim sh As Object
Application.EnableEvents = False
'Incrémentationdu N° de la photo du premier plan
Feuil1.[n°_Image] = ((Feuil1.[n°_Image]) Mod 9) + 1
Set sh = Feuil1.Shapes("Bandeau " & Feuil1.[n°_Image])
'Passage au premier plan
sh.ZOrder 0
Application.EnableEvents = True
End Sub
Sub ExecuteChangeBandeau()
'Changement de photo et planification de la prochaine photo
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
ChangeBandeau
Temps = Now + TimeValue("00:00:03")
Application.OnTime Temps, "ExecuteChangeBandeau"
End Sub
Sub Arrêt()
'Déplanification du «diaporama»
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
On Error Resume Next
Application.OnTime Temps, "ExecuteChangeBandeau", , False
On Error GoTo 0
End Sub
Sub Switch()
'Bouton ON/OFF du diaporama
Ctrl = Application.Caller
If Ctrl = "Bt_Switch" Then
With Feuil1.Shapes(Ctrl)
Select Case .DrawingObject.Text
Case "STOP"
.DrawingObject.Text = "GO"
Arrêt
Case "GO"
.DrawingObject.Text = "STOP"
ExecuteChangeBandeau
End Select
End With
End If
End Sub
Private Sub Worksheet_Activate()
AfficherBarreMenu
Me.Shapes("Bt_Switch").DrawingObject.Text = "STOP"
ExecuteChangeBandeau
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
'Si le changement vient d'un élément du calendrier, mettre à jour le planning
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
If Target.Address = Me.[AnnéeCal].Address Or Target.Address = Me.[MoisCal].Address Or Target.Address = Me.[DébutSemaine].Address Then
MàjPlanning
End If
End Sub
Private Sub Worksheet_Deactivate()
EffacerBarreMenu
Arrêt
Me.Shapes("Bt_Switch").DrawingObject.Text = "GO"
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Retirer le menu Compléments
EffacerBarreMenu
'Arrêt du «diaporama» dans le Bandeau
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
On Error Resume Next: Arrêt: On Error GoTo 0
Feuil1.Shapes("Bt_Switch").DrawingObject.Text = "GO"
End Sub
Private Sub Workbook_Open()
'Afficher le menu Complément si la feuille active est le planning
If ActiveSheet.Name = "Planning" Then AfficherBarreMenu
'Début du «diaporama» dans le Bandeau
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Feuil1.Shapes("Bt_Switch").DrawingObject.Text = "STOP"
ExecuteChangeBandeau
End Sub
We use cookies and similar technologies for the following purposes:
Est ce que vous acceptez les cookies et ces technologies?
We use cookies and similar technologies for the following purposes:
Est ce que vous acceptez les cookies et ces technologies?