Option Explicit
Private Sub CommandButton1_Click()
'Noms utilisés : SemaineDébut,SemaineFin,Parcelle,Planche,Culture
Dim IndexSemDeb, IndexSemFin, Derlig, L
On Error GoTo Fin:
IndexSemDeb = Application.Match(Val(UserForm1.SemaineDébut), Range("2:2"), 0) ' Repère du début
IndexSemFin = Application.Match(Val(UserForm1.SemaineFin), Range("2:2"), 0) ' Repère de la fin
Derlig = Range("B65500").End(xlUp).Row
For L = 3 To Derlig
If Cells(L, 2) = UserForm1.Parcelle And Cells(L, 3) = Val(UserForm1.Planche) Then Exit For ' Cherche Parcelle/Planche
Next L
' Met en couleurs ( aleatoires ! ) la plage trouvée
Range(Cells(L, IndexSemDeb), Cells(L, IndexSemFin)).Interior.Color = RGB(Int(255 * Rnd()), Int(255 * Rnd()), Int(255 * Rnd()))
Cells(L, IndexSemDeb) = Culture ' Inscrit la culture désirée.
Fin:
End Sub
Private Sub CommandButton2_Click()
Unload UserForm1
End Sub