Probleme sur une macro VBA
Pascalshanghai
Messages postés
5
Statut
Membre
-
Pascalshanghai Messages postés 5 Statut Membre -
Pascalshanghai Messages postés 5 Statut Membre -
Bonjour a tous,
Nouveau sur le site et débutant sur Excel VBA.
J'ai repris un document qu'une amie m’avait fait et l'ai modifie et donc j'ai du aussi modifie la macro.
Après bien des galères, j'ai cru que j'avais réussi jusqu'à ce que je descende sur les lignes plus bas et la, surprise a partir de la ligne 60 non seulement la fonction ne marche pas mais en plus il me colore les lignes en vert jusqu'à la ligne 1000. Par contre de la ligne 3 a 59 pas de problème cela fonctionne.
Le principe de la macro est de colorer la ligne concernée en fonction d'une réponse donnée via un menu déroulant, 3 possibilités donc 3 couleurs. De plus, j'ai rajoute une fonction de multiplication automatique .
Ci-dessous les 2 fonctions, si l'un de vous pouvait les vérifier et me dire ce qui ne va pas, cela serait vraiment sympa de votre part.
Je vous remercie d’avance.
Sub status_NonFood()
'
' status_NonFood Macro
' Macro recorded 5/26/2009 by Pascal HAITAYAN
'
'
Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("A3").Select
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39, Criteria1:="Cancelled"
Range("A3").Select
Selection.CurrentRegion.Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Range("A3").Select
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39, Criteria1:="Shipment Delayed"
Range("A3").Select
Selection.CurrentRegion.Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39, Criteria1:="Shipped on time"
Range("A1:AM1").Select
Selection.CurrentRegion.Select
Selection.Interior.ColorIndex = 35
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39
Range("A1:AM1").Select
Selection.CurrentRegion.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A1:AM2").Select
Selection.Interior.ColorIndex = xlNone
Application.CommandBars("Borders").Visible = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Range("A3").Select
End Sub
Sub status()
'
' status Macro
' Macro recorded 5/26/2009 by Pascal HAITAYAN
'
'
Cells.Select
Selection.Interior.ColorIndex = xlNone
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39, Criteria1:="Cancelled"
Range("A1:AM1").Select
Selection.CurrentRegion.Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Range("A3").Select
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39, Criteria1:="Shipment Delayed"
Range("A3").Select
Selection.CurrentRegion.Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39, Criteria1:="Shipped on time"
Range("A1:AM1").Select
Selection.CurrentRegion.Select
Selection.Interior.ColorIndex = 35
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39
Range("A1:AM1").Select
Selection.CurrentRegion.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A1:AM2").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Interior.ColorIndex = xlNone
Range("A3").Select
End Sub
Sub TotalUnit()
'
' TotalUnit Macro
' Macro recorded 6/2/2009 by YlmF
'
'
Range("L3").Select
ActiveCell.FormulaR1C1 = "=RC[-2]*RC[-1]"
Range("L3").Select
Selection.Copy
Range("L4:L1000").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub
Nouveau sur le site et débutant sur Excel VBA.
J'ai repris un document qu'une amie m’avait fait et l'ai modifie et donc j'ai du aussi modifie la macro.
Après bien des galères, j'ai cru que j'avais réussi jusqu'à ce que je descende sur les lignes plus bas et la, surprise a partir de la ligne 60 non seulement la fonction ne marche pas mais en plus il me colore les lignes en vert jusqu'à la ligne 1000. Par contre de la ligne 3 a 59 pas de problème cela fonctionne.
Le principe de la macro est de colorer la ligne concernée en fonction d'une réponse donnée via un menu déroulant, 3 possibilités donc 3 couleurs. De plus, j'ai rajoute une fonction de multiplication automatique .
Ci-dessous les 2 fonctions, si l'un de vous pouvait les vérifier et me dire ce qui ne va pas, cela serait vraiment sympa de votre part.
Je vous remercie d’avance.
Sub status_NonFood()
'
' status_NonFood Macro
' Macro recorded 5/26/2009 by Pascal HAITAYAN
'
'
Cells.Select
Selection.Interior.ColorIndex = xlNone
Range("A3").Select
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39, Criteria1:="Cancelled"
Range("A3").Select
Selection.CurrentRegion.Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Range("A3").Select
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39, Criteria1:="Shipment Delayed"
Range("A3").Select
Selection.CurrentRegion.Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39, Criteria1:="Shipped on time"
Range("A1:AM1").Select
Selection.CurrentRegion.Select
Selection.Interior.ColorIndex = 35
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39
Range("A1:AM1").Select
Selection.CurrentRegion.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A1:AM2").Select
Selection.Interior.ColorIndex = xlNone
Application.CommandBars("Borders").Visible = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Range("A3").Select
End Sub
Sub status()
'
' status Macro
' Macro recorded 5/26/2009 by Pascal HAITAYAN
'
'
Cells.Select
Selection.Interior.ColorIndex = xlNone
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39, Criteria1:="Cancelled"
Range("A1:AM1").Select
Selection.CurrentRegion.Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Range("A3").Select
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39, Criteria1:="Shipment Delayed"
Range("A3").Select
Selection.CurrentRegion.Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39, Criteria1:="Shipped on time"
Range("A1:AM1").Select
Selection.CurrentRegion.Select
Selection.Interior.ColorIndex = 35
ActiveWindow.SmallScroll ToRight:=39
Selection.AutoFilter Field:=39
Range("A1:AM1").Select
Selection.CurrentRegion.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A1:AM2").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Interior.ColorIndex = xlNone
Range("A3").Select
End Sub
Sub TotalUnit()
'
' TotalUnit Macro
' Macro recorded 6/2/2009 by YlmF
'
'
Range("L3").Select
ActiveCell.FormulaR1C1 = "=RC[-2]*RC[-1]"
Range("L3").Select
Selection.Copy
Range("L4:L1000").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub
A voir également:
- Probleme sur une macro VBA
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Télécharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Jitbit macro recorder - Télécharger - Confidentialité
- Excel compter cellule couleur sans vba - Guide
- Excel récupérer couleur cellule sans macro ✓ - Forum Bureautique
2 réponses
Bonjour,
En attendant réparation, vous devriez faire un mise en forme contionnelle (3 cas possibles) vous aurez de suite un résultat sécurisé...
En attendant réparation, vous devriez faire un mise en forme contionnelle (3 cas possibles) vous aurez de suite un résultat sécurisé...
Merci pour l'info mais qu'est ce qu'une forme contionnelle ?
Je suis débutant sur VBA et n'ai fait que reprendre une macro déjà crée.