T
Temjeh
Guest
Bonsoir à tous
Encore moi avec mes macros
J'ai ce code qui recherche valeur:
Sub Macro1()
'Code qui recherche valeur de InputBox
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
Debut:
strSearchString = InputBox(prompt:='Entrer le no de téléphone.', 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(' Le client au' & strSearchString & ' n'est pas enregistré ', 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
On Error GoTo Error
returnValue = MsgBox(' Le client ' & strSearchString & ' est enregistré 1 seule fois ', vbOKOnly, ' Message ')
Exit Sub
End If
If counter = countTot Then
On Error GoTo Error
returnValue = MsgBox(' Le client ' & strSearchString & ' sélectionné est le dernier !', vbOKOnly, 'Message')
Exit Sub
Else
On Error GoTo Error
returnValue = MsgBox(' Le client ' & strSearchString & ' sélectionné est le ' & counter & ' sur ' & countTot & ' existants. ' & 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
Error:
End Sub
J'ai besoin qu'il recherche sur tous les feuils comme il le fait mais que dans les colonnes A à E car en col F j'y met aussi un no de téléphone au travail que je ne veut pas dans la recherche.
Est-ce possible ou je rêve
Merci beaucoup
Temjeh
Encore moi avec mes macros
J'ai ce code qui recherche valeur:
Sub Macro1()
'Code qui recherche valeur de InputBox
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
Debut:
strSearchString = InputBox(prompt:='Entrer le no de téléphone.', 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(' Le client au' & strSearchString & ' n'est pas enregistré ', 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
On Error GoTo Error
returnValue = MsgBox(' Le client ' & strSearchString & ' est enregistré 1 seule fois ', vbOKOnly, ' Message ')
Exit Sub
End If
If counter = countTot Then
On Error GoTo Error
returnValue = MsgBox(' Le client ' & strSearchString & ' sélectionné est le dernier !', vbOKOnly, 'Message')
Exit Sub
Else
On Error GoTo Error
returnValue = MsgBox(' Le client ' & strSearchString & ' sélectionné est le ' & counter & ' sur ' & countTot & ' existants. ' & 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
Error:
End Sub
J'ai besoin qu'il recherche sur tous les feuils comme il le fait mais que dans les colonnes A à E car en col F j'y met aussi un no de téléphone au travail que je ne veut pas dans la recherche.
Est-ce possible ou je rêve
Merci beaucoup
Temjeh