For Each c In Selection ' A lire : http://excel-malin.com/tutoriels/vba-tutoriels/vba-select-case-mode-d-emploi/ Select Case (c.Value) Case 1: c.Interior.ColorIndex = 3 '"1" c.Font.ColorIndex = 2 Case 2: c.Interior.ColorIndex = 10 '"2" c.Font.ColorIndex = 2 Case 3: c.Interior.ColorIndex = 45 '"3" c.Font.ColorIndex = 1 Case 4: c.Interior.ColorIndex = 41 '"4" c.Font.ColorIndex = 2 Case 7: c.Interior.ColorIndex = 28 '"07" c.Font.ColorIndex = 1 End Select Next
For Each c In Selection
Select Case (c)
Case 1
...
case 2
La macro ci-dessous ne fonctionne plus
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionc.Interior.ColorIndex = 3
c.Interior.Color = RGB(255, 0, 0)
Dim c
Sub couleur_cellules()
Dim C As Range
Range("ba22:ba52").Copy
Range("c22,f22,I22,L22,O22,R22,U22,X22,AA22,AD22,AG22,AJ22,AM22,AP22,AS22").PasteSpecial Paste:=xlPasteFormats
Range("BG8:BG12").Copy
Range("AD8:AE12").PasteSpecial Paste:=xlPasteFormats
Range( _
"ad8,ad9,ad10,ad11,c22:c52,f22:f52,I22:I52,L22:L52,O22:O52,R22:R52,U22:U52,X22:X52,AA22:AA52,AD22:AD52,AG22:AG52,AJ22:AJ52,AM22:AM52,AP22:AP52,AS22:AS52,AV22:AV52" _
).Select
For Each C In Selection
Select Case C.Value
Case 1: C.Interior.ColorIndex = 3
C.Font.ColorIndex = 2
Case 2: C.Interior.ColorIndex = 10
C.Font.ColorIndex = 2
Case 3: C.Interior.ColorIndex = 45
C.Font.ColorIndex = 1
Case 4: C.Interior.ColorIndex = 41
C.Font.ColorIndex = 2
Case 7: C.Interior.ColorIndex = 28
C.Font.ColorIndex = 1
End Select
Next
End Sub
15 déc. 2017 à 12:14
J'ai pu constaté combien tu ma déjà sauvé. J reviens donc vers toi car une autre macro me pose problème.
On m'a fait cette macro pour créer des pdf avec le nom qui change autant de fois qu'il n'y a d’occurrences. Elle fonctionnait bien sur Excel 2010 par contre j'ai achté MS Office 2016 et rien ne va plus. Quand j'active la macro, s'affiche le message suivant : Erreur de compilation : Projet ou Bibliothèque introuvable.
PS: avant d'activer la macro, je dois :
1 Modifier l'imprimante et choisir AcrobatPDF
2 Dans le panneau propriété de l'imprimante Décocher se limiter aux polices système
Dans l'éditeur Macro
1 Aller dans l'onglet outil>Références
2 cocher Acrobat Distiller
Je te remercie par avance
Public Sub PrintToPDF_sens1()
Dim i As Integer
Dim myPDF As PdfDistiller
Dim PSFileName As String
Dim PDFFileName As String
Dim Dossier As String
For i = 1 To Range("AQ1").Value
Range("A1").Select
ActiveCell.FormulaR1C1 = i
Tri_sens_1
Dossier = "D:\REGION\Horaires à l'arrêt\Briey\Val de Briey Sens 1 -"
PSFileName = Dossier & Range("A12").Value & ".ps"
PDFFileName = Dossier & Range("A12").Value & ".pdf"
LOGFileName = Dossier & Range("A12").Value & ".log"
ActiveWindow.SelectedSheets.PrintOut copies:=1, Collate:=True, PrintToFile:=True, PrToFileName:=PSFileName
Set myPDF = New PdfDistiller
myPDF.FileToPDF PSFileName, PDFFileName, ""
Set myPDF = Nothing
Kill PSFileName
Kill LOGFileName
Next i
End Sub