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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| Public Sub Traitement_dossier()
Application.ScreenUpdating = False
' mémorisation classeur courant
Set CC = ActiveWorkbook
CC.Sheets(Nom_feuille_OF).Activate
i = 6
Dossier = Cells(i, 1)
Do While Dossier<> ""
Application.ScreenUpdating = True
Rows(i).Select
Application.ScreenUpdating = False
Nom_Client = Cells(i, CNomClient)
If Verif_nom(Nom_Client) = "Ok" Then
...
Else
MsgBox "Client " & Num_OF & " inexistant"
End If
i = i + 1
CC.Sheets(Nom_feuille_OF).Activate
Dossier= Cells(i, 1)
Loop
Application.ScreenUpdating = True
End Sub
Public Function Verif_nom(NomClient As String) As String
Dim xlAppl As Excel.Application
Dim ligne, colonne As Integer
Dim Matricule, Categorie, Desc, Classement, Ville As String
Rep_ref = "C:\Repertoire\"
Fichier_ref= "Liste des clients.xls"
Feuil = "Candidats"
Set xlAppl = New Excel.Application
Set exlFichier = xlAppl.Workbooks.Open(Rep_rf & Fichier_ref, ReadOnly:=True)
Set exlRange = exlFichier.Worksheets(Feuil).Range("B6", Range("B6").SpecialCells(xlLastCell))
Set Cel = exlRange.Find(What:=NomClient, LookAt:=xlWhole) '
If Not (Cel) Is Nothing Then ' Cas où le nom du client est trouvée
ligne = Cel.Row ' Récupère le numéro de la ligne sur laquelle se trouve le nom du client
colonne = Cel.Column ' Récupère le numéro de la colonne sur laquelle se trouve le nom du client
Ville = exlFichier.Worksheets(Feuil).Cells(ligne, ColVille)
If Ville <> "Paris" And Ville <> "Lyon" Then
Verif_nom = "Nok"
Cells(i, CMat) = "Client hors Ville"
Else
Verif_nom = "Ok"
Matricule = exlFichier.Worksheets(Feuil).Cells(ligne, 2)
Categorie = exlFichier.Worksheets(Feuil).Cells(ligne, 3)
Desc = exlFichier.Worksheets(Feuil).Cells(ligne, 4)
Classement = exlFichier.Worksheets(Feuil).Cells(ligne, 5)
Cells(i, 2) = Matricule
Cells(i, 3) = Categorie
Cells(i, 4) = Desc
Cells(i, 5) = Classement
End If
Else
Verif_nom = "Nok"
End If
Set exlRange = Nothing
Set Cel = Nothing
exlFichier.Close SaveChanges:=False
Set exlFichier = Nothing
xlAppl.Quit
Set xlApp = Nothing
End Function |
Partager