Bonjour,
je cherche une abreviation de ce code parce qu'il me parait tres long
If Feuil2.Cells(9, k).Value >= Feuil1.Cells(j, 1).Value And Feuil2.Cells(9, k).Value < Feuil1.Cells(j, 2).Value And Feuil1.Cells(j, 3).Text = "CDF" And Feuil1.Cells(j, 4).Text = "E" Then
Feuil2.Cells(10, k).Interior.ColorIndex = 35
Feuil2.Cells(11, k).Interior.ColorIndex = 35
Feuil2.Cells(12, k).Interior.ColorIndex = 35
Feuil2.Cells(13, k).Interior.ColorIndex = 35
Feuil2.Cells(14, k).Interior.ColorIndex = 35
Feuil2.Cells(15, k).Interior.ColorIndex = 35
Feuil2.Cells(16, k).Interior.ColorIndex = 35
Feuil2.Cells(17, k).Interior.ColorIndex = 35
Feuil2.Cells(18, k).Interior.ColorIndex = 35
Feuil2.Cells(19, k).Interior.ColorIndex = 35
Feuil2.Cells(20, k).Interior.ColorIndex = 35
Feuil2.Cells(21, k).Interior.ColorIndex = 35
Feuil2.Cells(22, k).Interior.ColorIndex = 35
End If
ces dernier ligne se repetent beaucoup et je cherche de les resumer dans une seule ligne
et merci
'si K est une lettre correspondant à ta colonne
k = "J"
Range(k & "10:" & k & "22").Interior.ColorIndex = 35
'Si c'est le Numéro de colonne:
k = 5
Range(Cells(10, k), Cells(22, k)).Interior.ColorIndex = 35
Sub test()
' pour l'exemple je met une valeur à k
k = 4
'le changement de couleur se fait sur la colonne désignée par k...
' A savoir.. dans mon exemple : la colonne 4 ...c'est à dire..la colonne : D
Range(Cells(10, k), Cells(22, k)).Interior.ColorIndex = 35
End Sub