T
Temjeh
Guest
Bonjour le forum
Oui, oui encore ce code(trouver ici) que j'utilise à toute les sauce et pour ma nouvelle compo...
Il recherche valeur dans tous les feuils et dans tous les cols.
J'aimerais le modifié pour une recherche dans toutes les feuils mais dans la col F seulement
Merci
Dim countTot As Byte
Dim counter As Byte
Dim ws As Worksheet
Dim foundCell As Range
Dim loopAddr As String
Private Sub CommandButton1_Click()
Dim countTot As Long
Dim counter As Long
Dim strSearchString As String
Dim ws As Object
Dim foundCell As Variant
Dim loopAddr As Variant
Dim returnValue As String
strSearchString = InputBox(Prompt:='Saisir la valeur à chercher.', Title:='Recherche')
If strSearchString = '' Then Exit Sub
For Each ws In Worksheets
countTot = countTot + Application.CountIf(ws.UsedRange, '=' & strSearchString)
Next ws
If countTot = 0 Then
returnValue = MsgBox(' La valeur ' & strSearchString & ' n'est pas enregistrée ', vbOKOnly, ' Message ')
Else
counter = 0
For Each ws In Worksheets
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 = 1 Then
returnValue = MsgBox(' La valeur ' & strSearchString & ' est enregistrée 1 seule fois ', vbOKOnly, ' Message ')
Exit Sub
End If
If counter = countTot Then
returnValue = MsgBox(' La valeur ' & strSearchString & ' sélectionnée est la dernière !', vbOKOnly, 'Message')
Exit Sub
Else
returnValue = MsgBox(' La valeur ' & strSearchString & ' sélectionnée est la ' & counter & ' sur ' & countTot & ' existantes. ' & vbLf & _
' Voulez vous continuer la recherche ? ', vbYesNo, 'Message')
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
End If
Merci beaucoup
Temjeh
Oui, oui encore ce code(trouver ici) que j'utilise à toute les sauce et pour ma nouvelle compo...
Il recherche valeur dans tous les feuils et dans tous les cols.
J'aimerais le modifié pour une recherche dans toutes les feuils mais dans la col F seulement
Merci
Dim countTot As Byte
Dim counter As Byte
Dim ws As Worksheet
Dim foundCell As Range
Dim loopAddr As String
Private Sub CommandButton1_Click()
Dim countTot As Long
Dim counter As Long
Dim strSearchString As String
Dim ws As Object
Dim foundCell As Variant
Dim loopAddr As Variant
Dim returnValue As String
strSearchString = InputBox(Prompt:='Saisir la valeur à chercher.', Title:='Recherche')
If strSearchString = '' Then Exit Sub
For Each ws In Worksheets
countTot = countTot + Application.CountIf(ws.UsedRange, '=' & strSearchString)
Next ws
If countTot = 0 Then
returnValue = MsgBox(' La valeur ' & strSearchString & ' n'est pas enregistrée ', vbOKOnly, ' Message ')
Else
counter = 0
For Each ws In Worksheets
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 = 1 Then
returnValue = MsgBox(' La valeur ' & strSearchString & ' est enregistrée 1 seule fois ', vbOKOnly, ' Message ')
Exit Sub
End If
If counter = countTot Then
returnValue = MsgBox(' La valeur ' & strSearchString & ' sélectionnée est la dernière !', vbOKOnly, 'Message')
Exit Sub
Else
returnValue = MsgBox(' La valeur ' & strSearchString & ' sélectionnée est la ' & counter & ' sur ' & countTot & ' existantes. ' & vbLf & _
' Voulez vous continuer la recherche ? ', vbYesNo, 'Message')
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
End If
Merci beaucoup
Temjeh