Bonsoir le forum
les deux code qui suivent me permette d'avoir un message si un nom de la colonne Q est retaper dans le tableau "B1:J154"
Mon problème est le suivant sur cette feuille j'ai des macro et elle bug toutes A nom = Target
de l'aide merci
Bonne soirée
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ad1 As String
Dim nom As String
Dim ad2 As String
ad = "B1:J154"
If Not Application.Intersect(Target, Range(ad)) Is Nothing Then
ad1 = Target.Address(0, 0)
nom = Target
If nom = "" Then Exit Sub
recherchemot
End If
End Sub
Private Sub recherchemot()
Dim firstAddress As String
Dim ad As String
Dim cel As Range
Dim ligne1 As Long
Dim ligne2 As Long
'ad = "a2:" & Sheets("hhh").Cells.SpecialCells(xlCellTypeLastCell).Address(0, 0) ' on recherche dans l'ensemble de la feuille
ad2 = "q4:q58"
With Sheets("Semaine 25").Range(ad2)
Set cel = .Find(nom, LookIn:=xlValues, SearchOrder:=xlByRows) ' on recherche ligne par ligne
If Not cel Is Nothing Then
firstAddress = cel.Address
Do
'ligne2 = cel.Row
'If ligne2 <> ligne1 Then ' on vérifie que la valeur n'a pas été trouvé sur la ligne
' remplir la listbox ou combobox ou Listview
'If cel.Address(0, 0) = ad1 Then
'Else
Select Case MsgBox("Le nom a été trouvé" _
& vbCrLf & "" _
& vbCrLf & "Cellule " & cel.Address(0, 0) _
, vbOKCancel Or vbCritical Or vbDefaultButton1, "Nom trouvé dans le tableau")
Case vbOK
Case vbCancel
Exit Sub
End Select
'End If
'End If
Set cel = .FindNext(cel) 'cellule suivante
Loop While Not cel Is Nothing And cel.Address <> firstAddress ' si on recommence la recherche alors fin de la recherche
End If
ligne2 = 0
End With
End Sub
les deux code qui suivent me permette d'avoir un message si un nom de la colonne Q est retaper dans le tableau "B1:J154"
Mon problème est le suivant sur cette feuille j'ai des macro et elle bug toutes A nom = Target
de l'aide merci
Bonne soirée
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ad1 As String
Dim nom As String
Dim ad2 As String
ad = "B1:J154"
If Not Application.Intersect(Target, Range(ad)) Is Nothing Then
ad1 = Target.Address(0, 0)
nom = Target
If nom = "" Then Exit Sub
recherchemot
End If
End Sub
Private Sub recherchemot()
Dim firstAddress As String
Dim ad As String
Dim cel As Range
Dim ligne1 As Long
Dim ligne2 As Long
'ad = "a2:" & Sheets("hhh").Cells.SpecialCells(xlCellTypeLastCell).Address(0, 0) ' on recherche dans l'ensemble de la feuille
ad2 = "q4:q58"
With Sheets("Semaine 25").Range(ad2)
Set cel = .Find(nom, LookIn:=xlValues, SearchOrder:=xlByRows) ' on recherche ligne par ligne
If Not cel Is Nothing Then
firstAddress = cel.Address
Do
'ligne2 = cel.Row
'If ligne2 <> ligne1 Then ' on vérifie que la valeur n'a pas été trouvé sur la ligne
' remplir la listbox ou combobox ou Listview
'If cel.Address(0, 0) = ad1 Then
'Else
Select Case MsgBox("Le nom a été trouvé" _
& vbCrLf & "" _
& vbCrLf & "Cellule " & cel.Address(0, 0) _
, vbOKCancel Or vbCritical Or vbDefaultButton1, "Nom trouvé dans le tableau")
Case vbOK
Case vbCancel
Exit Sub
End Select
'End If
'End If
Set cel = .FindNext(cel) 'cellule suivante
Loop While Not cel Is Nothing And cel.Address <> firstAddress ' si on recommence la recherche alors fin de la recherche
End If
ligne2 = 0
End With
End Sub