Calendrier automatique en VB

chasseur44

XLDnaute Occasionnel
Salut à Tous
J'ai récupéré ce script sur l'excellent site de FRED sig
Sub CalendrierAnnuel()

An$ = InputBox("Calendrier de l'année :", "", Year(Date))
If An = "" Then Exit Sub
Application.ScreenUpdating = False
[A:A].Clear
Range("A1").Value = DateSerial(An, 1, 1)
Range("A1").DataSeries _
xlColumns, xlDataSeriesLinear, xlDay, 1, DateSerial(An, 12, 31)
Range(Range("A1"), Cells(Rows.Count, 1).End(xlUp)).Select
Paques$ = _
"FRANC(DATE(ANNEE(A1);4;JOUR(MINUTE(ANNEE(A1)/38)/2+55))/7*7-6"
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OU(" & _
"A1=DATE(ANNEE(A1);1;1);" & _
Paques & "+1=A1;" & _
"A1=DATE(ANNEE(A1);5;1);" & _
"A1=DATE(ANNEE(A1);5;8);" & _
Paques & "+39=A1;" & _
Paques & "+50=A1;" & _
"A1=DATE(ANNEE(A1);7;14);" & _
"A1=DATE(ANNEE(A1);8;15);" & _
"A1=DATE(ANNEE(A1);11;1);" & _
"A1=DATE(ANNEE(A1);11;11);" & _
"A1=DATE(ANNEE(A1);12;25)" & _
")"
.FormatConditions(1).Interior.ColorIndex = 34
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=JOURSEM(A1;2)>5"
.FormatConditions(2).Interior.ColorIndex = 27
.NumberFormatLocal = "jjjj jj/mm/aaaa"
.HorizontalAlignment = xlLeft
End With
ActiveCell.Select
End Sub


Comment faire la même chose mais en colonne ?
Bien sur j'utilise excel 2007 !

Merci de votre aide
 

chasseur44

XLDnaute Occasionnel
Re : Calendrier automatique en VB

Ne cherchez plus
J'ai trouvé la solution en regardant de plus prés !
en modifiant legerement le script
[1:1].Clear
Range("A1").Value = DateSerial(An, 1, 1)
Range("A1").DataSeries _
xlRows, xlDataSeriesLinear, xlDay, 1, DateSerial(An, 12, 31)
Range(Range("A1"), Cells.End(xlToRight)).Select
 

Staple1600

XLDnaute Barbatruc
Re : Calendrier automatique en VB

Bonjour


Pour un simplissime calendrier en colonnes
Code:
Sub a()
Application.ScreenUpdating = False
With Range("A1:L1")
.FormulaR1C1 = "=DATEVALUE(""1/""&COLUMN())"
.Value = .Value
End With
Range("A1:L31").DataSeries Rowcol:=xlColumns, Type:=xlChronological, Date:= _
        xlDay, Step:=1, Trend:=False
Range("A1").CurrentRegion.NumberFormatLocal = "j/m/aaaa"
End Sub

PS: La section Téléchargement d'XLD regorge de calendriers sinon ;)
 

Staple1600

XLDnaute Barbatruc
Re : Calendrier automatique en VB

Re

Avec un peu de couleur
Code:
Sub b()
Application.ScreenUpdating = False
With Range("A1:L1")
.FormulaR1C1 = "=(""1/""&COLUMN())*1"
.Value = .Value
End With
Range("A1:L31").DataSeries Rowcol:=xlColumns, Type:=xlChronological, Date:= _
        xlDay, Step:=1, Trend:=False
With Range("A1").CurrentRegion
    .NumberFormatLocal = "jjj j/m/aaaa"
    .FormatConditions.Delete
    .FormatConditions.Add Type:=xlExpression, Formula1:="=JOURSEM(A1;2)>5"
    .FormatConditions(1).Interior.ColorIndex = 27
End With
End Sub

Sur mon PC, la partie du code de Frédéric SIGONNEAU dédiée au calcul du jour de Pâques ne fonctionne pas.
Donc avec ce calendrier, on ne fête pas Pâques, ce qui est bien pour notre santé ;)
 

Statistiques des forums

Discussions
312 330
Messages
2 087 337
Membres
103 524
dernier inscrit
Smile1813