Bon eh bien j'aurais du me douter que j'allais être confronté à un autre problème.
Je vais avoir une multitude de ligne sur lesquelles il va me falloir mettre des alertes mais je ne sais pas combien à l'avance.
Comment simplifier l'écriture suivante ? avec un tableau certainement mais comment ?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("F2") >= Range("N2") And Not Arret Then
MsgBox "Attention valeur atteinte sur cours A", vbExclamation + vbOKOnly
Arret = True
End If
If Range("F3") >= Range("N3") And Not Arret Then
MsgBox "Attention valeur atteinte sur cours B", vbExclamation + vbOKOnly
Arret = True
End If
If Range("F4") >= Range("N4") And Not Arret Then
MsgBox "Attention valeur atteinte sur cours C", vbExclamation + vbOKOnly
Arret = True
End If
If Range("F5") >= Range("N5") And Not Arret Then
MsgBox "Attention valeur atteinte sur cours D", vbExclamation + vbOKOnly
Arret = True
End If
If Range("F6") >= Range("N6") And Not Arret Then
MsgBox "Attention valeur atteinte sur cours E", vbExclamation + vbOKOnly
Arret = True
End If
If Range("F7") >= Range("N7") And Not Arret Then
MsgBox "Attention valeur atteinte sur cours F", vbExclamation + vbOKOnly
Arret = True
End If
If Range("F8") >= Range("N8") And Not Arret Then
MsgBox "Attention valeur atteinte sur cours G", vbExclamation + vbOKOnly
Arret = True
End If
If Range("F9") >= Range("N9") And Not Arret Then
MsgBox "Attention valeur atteinte sur cours H", vbExclamation + vbOKOnly
Arret = True
End If
If Range("F10") >= Range("10") And Not Arret Then
MsgBox "Attention valeur atteinte sur cours J", vbExclamation + vbOKOnly
Arret = True
End If
If Range("F11") >= Range("N11") And Not Arret Then
MsgBox "Attention valeur atteinte sur cours K", vbExclamation + vbOKOnly
Arret = True
End If
En plus le message box devra changer a chaque fois
If Range("F12") >= Range("N12") And Not Arret Then
MsgBox "Attention valeur atteinte sur cours L", vbExclamation + vbOKOnly
Arret = True
End If
End Sub
Le message box va changer en fonction de la ligne qui va s'activer et ajoutera le nom contenu dans B2, B3, B4, B5, etc...