re vinvin, le forum
Ton souci vient surement du fait que tu as inclus ta macro dans une boucle for each ws in worksheet.
Ce qui oblige à la macro d'appliquer ton code à toutes les feuilles, il faut surement supprimer cette boucle.
Ce qui devrait être fait dans le code suivant :
Dim countTot As Long
Dim counter As Long
Dim strSearchString As String
Dim Ws As Worksheet 'modif ici**************
Dim foundCell As Variant
Dim loopAddr As Variant
Dim returnValue As String
Dim strSearchString1 As String
Dim MyCollection As String
strSearchString = TxtNomVol.Value
strSearchString1 = TxtPrénomVol.Value
If strSearchString1 = '' Then strSearchString = '' Else
For Each Ws In Worksheets
countTot = countTot + Application.CountIf(Ws.UsedRange, '=' & strSearchString)
Next Ws
If countTot = 0 Then
returnValue = MsgBox(' Cette Personne : ' & strSearchString & ' ' & strSearchString1 & ' n'est pas connue de nos fichiers ', vbOKOnly, ' Message ')
Else
counter = 0
'For Each Ws In Worksheets'modif ici ********************
Set Ws = Sheets('RéCap')
With Ws
.Activate
Set foundCell = .Cells.Find(What:=strSearchString, LookIn:=xlValues, LookAt:=xlPart)
If Not foundCell Is Nothing Then
loopAddr = foundCell.Address
Do
counter = counter + 1
foundCell.Activate
If countTot = 2 Then
returnValue = MsgBox('Cette Personne : ' & strSearchString & ' ' & strSearchString1 & ' EST CONNUE DE NOS SERVICE, veuillez continué le constat de vol et intérroger le Récap. Interpelle ', vbOKOnly, ' Message ')
Exit Sub
End If
If counter = countTot Then
returnValue = MsgBox('Cette Personne : ' & strSearchString & ' sélectionnée est la dernière !', vbOKOnly, 'Message')
Exit Sub
Else
returnValue = MsgBox('Cette Personne : ' & strSearchString & ' ' & strSearchString1 & ' a été ' & countTot & vbLf)
If returnValue = vbNo Then Exit For
Set foundCell = .Cells.FindNext(After:=foundCell)
End If
Loop While Not foundCell Is Nothing And foundCell.Address <> loopAddr
End If
End With
'Next Ws modif Ici**************
End If
PAr contre, je n'ai pas testé, si tu pouvais, en cas de nouveau souci, joindre un fichier exemple ca serait plus facile.
salut