1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Sub test()
Dim x$, c1 As Range, c2 As Range, nums As Variant
x = InputBox("entrez un/deux numeros")
If x <> vbNullString And x Like "*#/#*" Then ' si on annule pas et que la chaine tapée correspond a un chiffre + "/" + un chiffre
nums = Split(x, "/")
With Sheets(1).Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row)
'on met tout en bleu au depart
.Parent.Range(.Cells(1, 1), .Cells(.Cells.Count)).Interior.Color = RGB(0, 150, 255)
'on cherche le 1°chiffre nom-+ nums(0)
Set c1 = .Find("nom-" & nums(0), lookat:=xlWhole)
'on cherche le 2d chiffre nom-+ nums(1)
Set c2 = .Find("nom-" & nums(1), lookat:=xlWhole)
'si c1 n'est pas rien
If Not c1 Is Nothing Then .Parent.Range(Cells(1, 1), c1).Interior.Color = RGB(255, 200, 50) Else mess = mess & "la cellule contenant ""nom-" & nums(0) & """ n'existe pas !!" & vbCrLf
'si c2 n'est pas rien
If Not c2 Is Nothing Then .Parent.Range(c2, .Cells(.Cells.Count)).Interior.Color = RGB(255, 200, 50) Else mess = mess & "la cellule contenant ""nom-" & nums(1) & """ n'existe pas !!" & vbCrLf
If mess <> "" Then MsgBox mess
End With
Else
MsgBox "la chaine tapée ne correspond pas a la chainne attendue!!!!"
End If
End Sub |
Partager