Microsoft 365 Y a t'il plus simple pour la formule

PORCHER

XLDnaute Occasionnel
Bonjour mes amis,
J'ai besoin de vous pour m'aider à trouver une solution suivant la macro ci-dessous
Je suis persuader qu'il y a plus simple pour formuler
VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Plage1, Plage2, Plage3, Plage4, Plage5, Plage6, Plage7, Plage8, Plage9, Plage10 As Range
Set Plage1 = ActiveSheet.Range("C4:L4")
Set Plage2 = ActiveSheet.Range("C7:L7")
Set Plage3 = ActiveSheet.Range("C9:L9")
Set Plage4 = ActiveSheet.Range("C11:L11")
Set Plage5 = ActiveSheet.Range("C13:L13")
Set Plage6 = ActiveSheet.Range("C15:L15")
Set Plage7 = ActiveSheet.Range("C18:L18")
Set Plage8 = ActiveSheet.Range("C20:L20")
Set Plage9 = ActiveSheet.Range("C22:L22")
Set Plage10 = ActiveSheet.Range("C24:L24")

'Création de la première règle
With Plage1.Font: .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3: End With
With Plage2.Font: .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3: End With
With Plage3.Font: .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3: End With
With Plage4.Font: .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3: End With
With Plage5.Font: .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3: End With
With Plage6.Font: .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3: End With
With Plage7.Font: .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3: End With
With Plage8.Font: .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3: End With
With Plage9.Font: .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3: End With
With Plage10.Font: .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3: End With
End Sub
Merci et très cordialement
 

fanfan38

XLDnaute Barbatruc
Bonjour
Un fichier est TOUJOURS le bienvenu
VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Dim i as integer
  with Range("C4:L4")    'Création de la première règle
   .Font: .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3
  end with
for i=9 to 24 step 2
 with range(cells(i,3),cells(i,12)) 
  .Font: .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3
 end with
next
End Sub
En l'absence de fichier la macro n'a pas été testée....

A+ François
 

job75

XLDnaute Barbatruc
Bonjour PORCHER, fanfan38,

Puisqu'on formate toutes les plages de la même manière :
VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Range("C4:L4,C7:L7,C9:L9,C11:L11,C13:L13,C15:L15,C18:L18,C20:L20,C22:L22,C24:L24").Font
    .Name = "Arial": .Size = 10: .Bold = True: .ColorIndex = 3
End With
ActiveCell.Activate
End Sub
A+
 

Discussions similaires

Réponses
6
Affichages
613

Statistiques des forums

Discussions
315 098
Messages
2 116 189
Membres
112 679
dernier inscrit
Yupanki