djvincebaya
XLDnaute Nouveau
bonjour,
je suis nouveau sur ce forum et je sollicite votre aide pour corriger ce code vba qui ne fonctionne pas
Voici mon problème : quand j'exécute le code suivant
Private Sub CommandButton2_Click()
Dim l As Integer 'n° ligne
Dim c As Integer 'n° colonne
If mois.Value = "JANVIER" Then l = 1: End
If mois.Value = "JANVIER" Then c = 1: End
If mois.Value = "FEVRIER" Then l = 1: End
If mois.Value = "FEVRIER" Then c = 23: End
If mois.Value = "MARS" Then l = 1: End
If mois.Value = "MARS" Then c = 45: End
If mois.Value = "AVRIL" Then l = 1: End
If mois.Value = "AVRIL" Then c = 67: End
If mois.Value = "MAI" Then l = 1: End
If mois.Value = "MAI" Then c = 89: End
If mois.Value = "JUIN" Then l = 1: End
If mois.Value = "JUIN" Then c = 111: End
If mois.Value = "JUILLET" Then l = 68: End
If mois.Value = "JUILLET" Then c = 1: End
If mois.Value = "AOUT" Then l = 68: End
If mois.Value = "AOUT" Then c = 23: End
If mois.Value = "SEPTEMBRE" Then l = 68: End
If mois.Value = "SEPTEMBRE" Then c = 45: End
If mois.Value = "OCTOBRE" Then l = 68: End
If mois.Value = "OCTOBRE" Then c = 67: End
If mois.Value = "NOVEMBRE" Then l = 68: End
If mois.Value = "NOVEMBRE" Then c = 89: End
If mois.Value = "DECEMBRE" Then l = 68: End
If mois.Value = "DECEMBRE" Then c = 111: End
'mois
Application.Goto (ActiveWorkbook.Sheets(1).Range(Cells(l + 6, c), Cells(l + 15, c + 1)))
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
With Selection.Font
.Name = "Times New Roman"
.Size = 26
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
ActiveCell.FormulaR1C1 = mois.Value
l'erreur d'exécution 1004 apparaît (erreur définie par l'application ou par l'objet).
C'est le code en rouge qui ne fonctionne pas mais je ne trouve pas d'où vient l'erreur.
Quelqu'un peut-il aider un débutant se débatant désespéremment dans le langage vba?
par avance merci.
Vince
je suis nouveau sur ce forum et je sollicite votre aide pour corriger ce code vba qui ne fonctionne pas
Voici mon problème : quand j'exécute le code suivant
Private Sub CommandButton2_Click()
Dim l As Integer 'n° ligne
Dim c As Integer 'n° colonne
If mois.Value = "JANVIER" Then l = 1: End
If mois.Value = "JANVIER" Then c = 1: End
If mois.Value = "FEVRIER" Then l = 1: End
If mois.Value = "FEVRIER" Then c = 23: End
If mois.Value = "MARS" Then l = 1: End
If mois.Value = "MARS" Then c = 45: End
If mois.Value = "AVRIL" Then l = 1: End
If mois.Value = "AVRIL" Then c = 67: End
If mois.Value = "MAI" Then l = 1: End
If mois.Value = "MAI" Then c = 89: End
If mois.Value = "JUIN" Then l = 1: End
If mois.Value = "JUIN" Then c = 111: End
If mois.Value = "JUILLET" Then l = 68: End
If mois.Value = "JUILLET" Then c = 1: End
If mois.Value = "AOUT" Then l = 68: End
If mois.Value = "AOUT" Then c = 23: End
If mois.Value = "SEPTEMBRE" Then l = 68: End
If mois.Value = "SEPTEMBRE" Then c = 45: End
If mois.Value = "OCTOBRE" Then l = 68: End
If mois.Value = "OCTOBRE" Then c = 67: End
If mois.Value = "NOVEMBRE" Then l = 68: End
If mois.Value = "NOVEMBRE" Then c = 89: End
If mois.Value = "DECEMBRE" Then l = 68: End
If mois.Value = "DECEMBRE" Then c = 111: End
'mois
Application.Goto (ActiveWorkbook.Sheets(1).Range(Cells(l + 6, c), Cells(l + 15, c + 1)))
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
With Selection.Font
.Name = "Times New Roman"
.Size = 26
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
ActiveCell.FormulaR1C1 = mois.Value
l'erreur d'exécution 1004 apparaît (erreur définie par l'application ou par l'objet).
C'est le code en rouge qui ne fonctionne pas mais je ne trouve pas d'où vient l'erreur.
Quelqu'un peut-il aider un débutant se débatant désespéremment dans le langage vba?
par avance merci.
Vince