1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| Private Const SW_SHOWNORMAL = 1
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub Macro_Recherche()
Dim Str_Plage As String
Dim Cel As Range
Dim Feuil As Worksheet
Dim Str_critère As String
Dim X As Byte
Str_Plage = "B:B"
Str_critère = InputBox("Article à rechercher ?")
For Each Feuil In Sheets
For Each Cel In Feuil.Range(Str_Plage)
If UCase(Cel) Like "*" & UCase(Str_critère) & "*" Then
Feuil.Activate
Cel.Activate
X = MsgBox("Mot """ & Str_critère & """ trouvé :" & Chr(13) & _
"Sur la feuille : " & Feuil.Name & Chr(13) & _
"à la cellule : " & Cel.Address(0, 0) & Chr(13) & Chr(13) & _
"Oui : Lancer fichier" & Chr(13) & _
"Non : on continue la recherche " & Chr(13), vbDefaultButton2 + _
vbQuestion + vbYesNo, "MOT TROUVÉ")
Select Case X
Case 6
Dim fich As String
Feuil1.Activate
Cel.Activate
' ActiveCell.Offset(0, 1).Select
'Fich = ActiveCell
ActiveCell.Offset(0, 1).Select
fich = ActiveCell.Text
ShellExecute 0, "open", fich, "", "", SW_SHOWNORMAL
Exit Sub
Case 2 'annuler on sort
Exit Sub
Case Else 'Non=7
'on fait rien, mais on pourrait
End Select
End If
Next Cel
Next Feuil
MsgBox ("pas trouvé")
End Sub |
Partager