Macro VBA

Fermé
eglantine217 Messages postés 54 Date d'inscription mardi 8 mai 2012 Statut Membre Dernière intervention 3 mars 2013 - 5 sept. 2012 à 13:08
ccm81 Messages postés 10854 Date d'inscription lundi 18 octobre 2010 Statut Membre Dernière intervention 26 avril 2024 - 5 sept. 2012 à 19:03
Bonjour,

j'ai créé une macro pour la mise en forme conditionnelle
cette macro est valable pour 3 onglets de mon fichier excel
comment faire pour exécuter qu'une seule fois cette macro (au lieu d'aller sur chaque onglet puis cliquer sur exécuter)
merci d'avance


Sub conditionnal_formating()

With Range("F:F")
.FormatConditions.Delete
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="tata"
'couleur turquoise
.FormatConditions(1).Interior.ColorIndex = 8

.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="titi"
'couleur bleu clair
.FormatConditions(2).Interior.ColorIndex = 34
End With

For i = 12 To 500

' 8<U<19 orange clair B-E et G-U
If Range("F" & i) = "tata" And Range("U" & i) >= 8 And Range("U" & i) <= 19 Then
Range("B" & i, "E" & i).Interior.ColorIndex = 40 'orange +
Range("G" & i, "AA" & i).Interior.ColorIndex = 40 'orange +


elseif ....... reste du code

End If
Next i

End Sub
A voir également:

1 réponse

ccm81 Messages postés 10854 Date d'inscription lundi 18 octobre 2010 Statut Membre Dernière intervention 26 avril 2024 2 404
5 sept. 2012 à 19:03
bonjour

peut être comme ça

For Each ws In Sheets
  ws.Select
  with activesheet.range("F:F")


  end with
Next ws


bonne suite
0