Pascalshanghai
Messages postés4Date d'inscriptionmercredi 3 juin 2009StatutMembreDernière intervention 8 juin 2009
-
4 juin 2009 à 03:53
Pascalshanghai
Messages postés4Date d'inscriptionmercredi 3 juin 2009StatutMembreDernière intervention 8 juin 2009
-
8 juin 2009 à 04:00
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
Bonjour,
La mise en forme conditionnelle s'obtient sans passer par Vba, dans votre fichier excel selectionner la colonne puis faire format mise en forme conditionnelle.
Pascalshanghai
Messages postés4Date d'inscriptionmercredi 3 juin 2009StatutMembreDernière intervention 8 juin 2009 8 juin 2009 à 04:00
Merci, mais la forme conditionnelle ne prends en compte que la cellule concernée moi de que je souhaite c'est de pouvoir colorer toute la ligne en fonction de la réponse de la dernière colonne
Discussions sur les outils et logiciels de bureautique. Trouvez des solutions à vos problèmes, apprenez des astuces pour maximiser votre productivité et connectez-vous avec une communauté dédiée à l'efficacité au travail.
5 juin 2009 à 04:06
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.