Erreur de compilation
k
Bonjour a tous
Je me suis lancé pour faire le calendrier de la formation excel pratique je suis a la video 20 et j'ai une erreur de compilation Next sans for
et aussi les lignes des jours 31 ne sont pas en trait plein
je ne touve pas les erreurs pourriez vous m'aider pour que je puisse continuer je vous met le code
Sub generer_calendrier()
Application.ScreenUpdating = False
annee = SpinBotton_annee.Value
'suppression
Range("A3:X33").ClearContents
Range("C31:D31").Borders.LineStyle = Range("A1").Borders.LineStyle
Range("C31:D31").Interior.Color = Range("A1").Interior.Color
'Tableau
derniere_ligne = Sheets("BD_CAL").Range("65000").End(xlUp).Row
If derniere_ligne > 1 Then 'si BD non vide
Dim tab_bd()
ReDim tab_bd(derniere_ligne - 2, 2)
For i = 0 To UBound(tab_bd, 1)
tab_bd(i, 0) = Sheets("BD_CAL").Cells(i + 2, 1)
tab_bd(i, 1) = Sheets("BD_CAL").Cells(i + 2, 2)
tab_bd(i, 2) = Sheets("BD_CAL").Cells(i + 2, 3)
Next
End If
'boucle MOIS
For mois = 1 To 12
nb_jours = Day(DateSerial(annee, mois + 1, 1) - 1)
colonne = mois * 2 - 1
'boucle jour
For jour = 1 To nb_jours
date_du_jour = DateSerial(annee, mois, jour)
Cells(jour + 2, colonne) = date_du_jour
'Test Weekend
If Weekday(date_du_jour) = 1 Or Weekday(date_du_jour) = 7 Then 'Si Week End
Cells(jour + 2, colonne).Interior.Color = RGB(192, 224, 255)
Cells(jour + 2, colonne + 1).Interior.Color = RGB(192, 224, 255)
Else 'Si autre chose
Cells(jour + 2, colonne).Interior.Color = RGB(255, 255, 255)
Cells(jour + 2, colonne + 1).Interior.Color = RGB(255, 255, 255)
End If
'BORDURES
'Gauche
With Cells(jour + 2, colonne).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
End With
With Cells(jour + 2, colonne).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlHairline
End With
With Cells(jour + 2, colonne).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
End With
If Weekday(date_du_jour) = 1 Then 'si dimanche
With Cells(jour + 2, colonne).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End If
If jour = nb_jours Then
With Cells(jour + 2, colonne).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
End With
'Droite
With Cells(jour + 2, colonne + 1).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
End With
If mois = 12 Or jour > 28 Then
With Cells(jour + 2, colonne + 1).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
End With
End If
If Weekday(date_du_jour) = 1 Then 'si dimanche
With Cells(jour + 2, colonne).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End If
If jour = nb_jours Then
With Cells(jour + 2, colonne + 1).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
End With
'Affichage des données
If derniere_ligne > 1 Then 'si BD non vide
For i = 0 To UBound(tab_bd, 1)
If tab_bd(i, 0) = date_du_jour Then
Cells(jour + 2, colonne + 1) = tab_bd(i, 1)
couleur = tab_bd(i, 2)
If no_couleur = 0 Then
Cells(jour + 2, colonne + 1).Interior.Color = RGB(50, 205, 50) ';;166 219 111
ElseIf no_couleur = 1 Then
Cells(jour + 2, colonne + 1).Interior.Color = RGB(3, 180, 200) '101;183;219
ElseIf no_couleur = 2 Then
Cells(jour + 2, colonne + 1).Interior.Color = RGB(255, 0, 0) ' 219, 125, 111
ElseIf no_couleur = 3 Then
Cells(jour + 2, colonne + 1).Interior.Color = RGB(229, 223, 78)
ElseIf no_couleur = 4 Then
Cells(jour + 2, colonne + 1).Interior.Color = RGB(233, 196, 59)
ElseIf no_couleur = 5 Then
Cells(jour + 2, colonne + 1).Interior.Color = RGB(190, 190, 190)
End If
End If
Next
End If
Next
Next
End SubEdit modo : code mis entre balises, merci d'y faire attention la prochaine fois
bonjour,
merci à l'avenir de mettre ton code en utilisant le bouton </> et je te conseille fortement d'indenter ton code pour y voir plus clair
voici une correction
Sub generer_calendrier()
Application.ScreenUpdating = False
annee = SpinBotton_annee.Value
'suppression
Range("A3:X33").ClearContents
Range("C31:D31").Borders.LineStyle = Range("A1").Borders.LineStyle
Range("C31:D31").Interior.Color = Range("A1").Interior.Color
'Tableau
derniere_ligne = Sheets("BD_CAL").Range("A65000").End(xlUp).Row
If derniere_ligne > 1 Then 'si BD non vide
Dim tab_bd()
ReDim tab_bd(derniere_ligne - 2, 2)
For i = 0 To UBound(tab_bd, 1)
tab_bd(i, 0) = Sheets("BD_CAL").Cells(i + 2, 1)
tab_bd(i, 1) = Sheets("BD_CAL").Cells(i + 2, 2)
tab_bd(i, 2) = Sheets("BD_CAL").Cells(i + 2, 3)
Next
End If
'boucle MOIS
For mois = 1 To 12
nb_jours = Day(DateSerial(annee, mois + 1, 1) - 1)
colonne = mois * 2 - 1
'boucle jour
For jour = 1 To nb_jours
date_du_jour = DateSerial(annee, mois, jour)
Cells(jour + 2, colonne) = date_du_jour
'Test Weekend
If Weekday(date_du_jour) = 1 Or Weekday(date_du_jour) = 7 Then 'Si Week End
Cells(jour + 2, colonne).Interior.Color = RGB(192, 224, 255)
Cells(jour + 2, colonne + 1).Interior.Color = RGB(192, 224, 255)
Else
'Si autre chose
Cells(jour + 2, colonne).Interior.Color = RGB(255, 255, 255)
Cells(jour + 2, colonne + 1).Interior.Color = RGB(255, 255, 255)
End If
'BORDURES
'Gauche
With Cells(jour + 2, colonne).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
End With
With Cells(jour + 2, colonne).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlHairline
End With
With Cells(jour + 2, colonne).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
End With
If Weekday(date_du_jour) = 1 Then 'si dimanche
With Cells(jour + 2, colonne).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End If
If jour = nb_jours Then
With Cells(jour + 2, colonne).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
End With
'Droite
With Cells(jour + 2, colonne + 1).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
End With
If mois = 12 Or jour > 28 Then
With Cells(jour + 2, colonne + 1).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
End With
End If
If Weekday(date_du_jour) = 1 Then 'si dimanche
With Cells(jour + 2, colonne).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End If
If jour = nb_jours Then
With Cells(jour + 2, colonne + 1).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
End With
'Affichage des données
If derniere_ligne > 1 Then 'si BD non vide
For i = 0 To UBound(tab_bd, 1)
If tab_bd(i, 0) = date_du_jour Then
Cells(jour + 2, colonne + 1) = tab_bd(i, 1)
couleur = tab_bd(i, 2)
If no_couleur = 0 Then
Cells(jour + 2, colonne + 1).Interior.Color = RGB(50, 205, 50) ';;166 219 111
ElseIf no_couleur = 1 Then
Cells(jour + 2, colonne + 1).Interior.Color = RGB(3, 180, 200) '101;183;219
ElseIf no_couleur = 2 Then
Cells(jour + 2, colonne + 1).Interior.Color = RGB(255, 0, 0) ' 219, 125, 111
ElseIf no_couleur = 3 Then
Cells(jour + 2, colonne + 1).Interior.Color = RGB(229, 223, 78)
ElseIf no_couleur = 4 Then
Cells(jour + 2, colonne + 1).Interior.Color = RGB(233, 196, 59)
ElseIf no_couleur = 5 Then
Cells(jour + 2, colonne + 1).Interior.Color = RGB(190, 190, 190)
End If
End If
Next
End If
End If
End If
Next
Next
End Subk
bonjour,
merci pour le résumé, pour le code je ne connais pas il faut insérer mes quoi peu tu me dire svp
bonne soirée
k
bonjour a tous
mon problème est résolu
je vous souhaite une très bonne fin année