P
Patrick
Guest
Bonjour à toutes et à tous.
J'aimerais modifier une macro existante, mais je ne sais pas trop comment m'y prendre.
Suite au choix dans un listbox, la macro effectue une recherche de la valeur indiquée ds tt les feuilles du classeur, et ouvre la ou les feuilles en question.
Le pb c'est que j'aimerais éliminer de la recherche une feuille qui s'appelle 'listedossiers'.
Je joins ci-dessous la macro. Si quelqu'un peut m'aider à modifier ce code, ce serait sympa
merci par avance
Patrick
code:
Private Sub ListBox1_Click()
Dim strSearchString As String
Dim ws As Worksheet
Dim foundCell As Range
Dim returnValue As Variant
Dim countTot As Long
Dim counter As Long
strSearchString = ListBox1.Text
If ListBox1.Text = '' Then
MsgBox ('veuillez rentrer une valeur'), vbOKCancel
If vbCancel Then
Exit Sub
Unload UserForm1
End If
End If
For Each ws In Worksheets
countTot = countTot + Application.CountIf( _
ws.UsedRange, '=' & strSearchString)
Next ws
If countTot = 0 Then
MsgBox ' La valeur ' & strSearchString & Chr(10) & 'n'existe pas dans le planning.'
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
counter = counter + 1
foundCell.Activate
returnValue = MsgBox('La valeur cherchée ' & strSearchString & _
' a été trouvé semaine: ' & ws.Name & ' cellule ' & foundCell.Address & vbNewLine & _
'(' & counter & ' de ' & countTot & ')', vbOKCancel)
If returnValue = vbCancel Then
Exit For
Else
If counter = countTot Then Exit For
End If
End If
End With
Next ws
Unload UserForm1
End If
End Sub
J'aimerais modifier une macro existante, mais je ne sais pas trop comment m'y prendre.
Suite au choix dans un listbox, la macro effectue une recherche de la valeur indiquée ds tt les feuilles du classeur, et ouvre la ou les feuilles en question.
Le pb c'est que j'aimerais éliminer de la recherche une feuille qui s'appelle 'listedossiers'.
Je joins ci-dessous la macro. Si quelqu'un peut m'aider à modifier ce code, ce serait sympa
merci par avance
Patrick
code:
Private Sub ListBox1_Click()
Dim strSearchString As String
Dim ws As Worksheet
Dim foundCell As Range
Dim returnValue As Variant
Dim countTot As Long
Dim counter As Long
strSearchString = ListBox1.Text
If ListBox1.Text = '' Then
MsgBox ('veuillez rentrer une valeur'), vbOKCancel
If vbCancel Then
Exit Sub
Unload UserForm1
End If
End If
For Each ws In Worksheets
countTot = countTot + Application.CountIf( _
ws.UsedRange, '=' & strSearchString)
Next ws
If countTot = 0 Then
MsgBox ' La valeur ' & strSearchString & Chr(10) & 'n'existe pas dans le planning.'
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
counter = counter + 1
foundCell.Activate
returnValue = MsgBox('La valeur cherchée ' & strSearchString & _
' a été trouvé semaine: ' & ws.Name & ' cellule ' & foundCell.Address & vbNewLine & _
'(' & counter & ' de ' & countTot & ')', vbOKCancel)
If returnValue = vbCancel Then
Exit For
Else
If counter = countTot Then Exit For
End If
End If
End With
Next ws
Unload UserForm1
End If
End Sub