Erreur d'exécution 5
bonjour,
d'abord merci pour les cours vba, ils sont vraiment très très utile ;)
j'aurai besoin d'un petit coup de pouce pour debugger ma macro.
je coince sur une erreur 5 que je ne comprend pas.
si il y a d'autre bug je suis preneur d'explication
merci d'avance.
Sub Macro4()
'
' Macro4 Macro
'
'
Dim NLIGNES As Integer
Dim DATEFACT As Date
Dim AUJOURDHUI As Date
Dim NMONTANT As Integer
Dim NDATEFACT As Date
AUJOURDHUI = Date
For NLIGNES = 10 To 210
DATEFACT = Cells("NLIGNES,24")
If DATEFACT = "" And Cells("NLIGNES,25") = "" And Cells("NLIGNES,26") = "" And Cells("NLIGNES,27") = "" And Cells("NLIGNES,28") = "" And Cells("NLIGNES,29") = "" And Cells("NLIGNES,30") = "" And Cells("NLIGNES,31") = "" And Cells("NLIGNES,32") = "" Then
Rows("NLIGNES").Select
Selection.Cut
ActiveSheet("SOLDÉES").Select
Rows("NLIGNES").Select
ActiveSheet.past
Application.CutCopyMode = False
ActiveSheet("TABLE").Select
Else
If DATEFACT >= AUJOURDHUI Then
Select Case MsgBox("Voulez-vous facturer le cells(NLIGNES,3)?", vbYesNo, "FATURATION")
Case vbYes
Select Case MsgBox("Facturation de cells(NLIGNES,25)€", vbYesNo, "FACTURACTION cells(NLIGNES,3)")
Case vbYes
Cells("NLIGNES,24").Select
Selection.Cut
Cells("NLIGNES,23").Select
ActiveSheet.Paste
Cells("NLIGNES,18").Select
Selection.Cut
Range("W6").Select
ActiveSheet.Paste
Cells("NLIGNES,25").Select
Selection.Cut
Range("X6").Select
ActiveSheet.Paste
Range("Y6").Select
ActiveCell.FormulaR1C1 = "=RC[-2]+RC[-1]"
Range("Y6").Select
Selection.Copy
Range("Y6,Z6").Select
Range("Z6").Activate
ActiveSheet.Paste
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("Z6").Select
Application.CutCopyMode = False
Selection.Copy
Cells("NLIGNES,18").Select
ActiveSheet.Paste
Application.CutCopyMode = False
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Cells("NLIGNES,26:NLIGNES,31").Select
Selection.Copy
Cells("NLIGNES,24:NLIGNES,29").Select
ActiveSheet.Paste
Cells("NLIGNES,30:NLIGNES,31").Select
Selection.ClearContents
Range("W6:Z6").Select
Selection.Style = "Normal 2"
Selection.ClearContents
Cells("NLIGNES,22").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDot
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Case vbNo
NMONTANT = InputBox("Quelle est le nouveau montant a facturer ?", "NOUVEAU MONTANT")
Cells("NLIGNES,24").Select
Selection.Cut
Cells("NLIGNES,23").Select
ActiveSheet.Paste
Cells("NLIGNES,18").Select
Selection.Cut
Range("W6").Select
ActiveSheet.Paste
Range("X6") = NMONTANT
Range("Y6").Select
ActiveCell.FormulaR1C1 = "=RC[-2]+RC[-1]"
Range("Y6").Select
Selection.Copy
Range("Y6,Z6").Select
Range("Z6").Activate
ActiveSheet.Paste
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("Z6").Select
Application.CutCopyMode = False
Selection.Copy
Cells("NLIGNES,18").Select
ActiveSheet.Paste
Application.CutCopyMode = False
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Cells("NLIGNES,26:NLIGNES,31").Select
Selection.Copy
Cells("NLIGNES,24:NLIGNES,29").Select
ActiveSheet.Paste
Cells("NLIGNES,30:NLIGNES,31").Select
Selection.ClearContents
Range("W6:Z6").Select
Selection.Style = "Normal 2"
Selection.ClearContents
Cells("NLIGNES,22").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDot
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
End Select
Case vbNo
NDATEFACT = InputBox("Nouvelle date de facturation ?", "RECALAGE DE DATE")
Cells(NLIGNES, 24) = NDATEFACT
End Select
End If
End If
Next
End SubBonjour
Oui normal vous mettez des guillemets dans cette instruction --> DATEFACT = Cells("NLIGNES, 24")
Comme ceci :
DATEFACT = Cells(NLIGNES, 24)En regardant votre code :
- Il faut mieux préciser la feuille sur laquelle vous exécutez le code. Là on voit bien colonne 24 mais ne sait pas sur quelle feuille vous êtes et on se demande pourquoi vous bouclez jusque 210
- Evitez aussi les Select. Cela vient probablement de l'enregistreur automatique que vous avez utilisé. C'est bien mais après vous pouvez optimiser.
NB : Evitez aussi les accents et espaces dans le nom de vos feuilles quand vous utilisez VBA.
Crdlt
Merci beaucoup ça m'a bien aidé ça m'a permis de changer mon code