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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
| Dim nom As String, prenom As String, code As String, ecole As String, commune As String, i As Integer
Dim ecoleaff As String, pointaff As String, posteaff As String, communeaff As String, affectation As String, speaff As String
Sub regEx()
Dim Phrase As String, Phrase2 As String, Index As Integer, Pattern As String, nom2 As String, activite As Integer
Dim lig As Long
Application.ScreenUpdating = False
For lig = 36 To 21313
'For lig = 21216 To 25313
'MsgBox Cells(lig, 1).Value
'''''''' TEST POUR LE NOM ET PRENOM
If Cells(lig, 1).Value Like " M.*" Or Cells(lig, 1).Value Like " MME*" Then
'' test si pas de voeux ou erreur ou continue
If nom <> "" And affectation <> "" Then
'MsgBox "nom :" & nom & " prenom :" & prenom & " code" & code & " ecole " & ecole & " commune " & commune & " affectation " & affectation
Call Valeur_cherchee(nom, prenom, affectation, communeaff, ecoleaff, posteaff, pointaff, speaff)
nom = ""
prenom = ""
code = ""
ecole = ""
affectation = ""
commune = ""
communeaff = ""
ecoleaff = ""
posteaff = ""
pointaff = ""
speaff = ""
GoTo suite
Else
If nom <> "" And affectation = "" Then
affectation = "Aucun"
communeaff = "rien"
ecoleaff = "rien"
posteaff = "rien"
pointaff = "rien"
speaff = "rien"
'MsgBox "nom :" & nom & " prenom :" & prenom & " code" & code & " ecole " & ecole & " commune " & commune & " affectation " & affectation
Call Valeur_cherchee(nom, prenom, affectation, communeaff, ecoleaff, posteaff, pointaff, speaff)
nom = ""
prenom = ""
code = ""
ecole = ""
affectation = ""
commune = ""
communeaff = ""
ecoleaff = ""
posteaff = ""
ptaff = ""
GoTo suite
Else
If nom = "erreur" Then
i = i + 1
ThisWorkbook.Sheets("HS").Cells(i, 1).Value = Phrase
Workbooks("voeux.xlsm").Sheets("voeux").Activate
End If
nom = ""
prenom = ""
code = ""
ecole = ""
affectation = ""
commune = ""
communeaff = ""
ecoleaff = ""
posteaff = ""
pointaff = ""
speaff = ""
GoTo suite
End If
suite:
Phrase = Cells(lig, 1).Value
Phrase = Replace(Phrase, " DPE", " DPE")
Phrase = Replace(Phrase, " ST ", " ST ")
Phrase = Replace(Phrase, " SEGPA ", " SEGPA ")
Phrase = Replace(Phrase, " E.E.", " E.E.")
Phrase = Replace(Phrase, " E.M.", " E.M.")
Phrase = Replace(Phrase, " IEN ", " IEN ")
Phrase = Replace(Phrase, " CLG", " CLG")
Phrase = Replace(Phrase, "ENS.CL.ELE ", "ENS.CL.ELE ")
Phrase = Replace(Phrase, "ENS.CL.MA ", "ENS.CL.MA ")
If Cells(lig, 1).Value Like "* ACTIVITE *" Then
activite = 1
Pattern = "(?:\s)(?:\w+\.?) {2,}(?:((?:[-A-Z]+ )+) +((?:[-A-Z]+ )+) +((?:[-A-Z]+ )+))"
'Phrase = Application.Trim(Cells(lig, 1).Value)
'If inc = 2 Then nom = Mot
'If inc = 3 Then prenom1 = Mot
'If inc = 4 Then prenom2 = Mot
'If prenom2 Like "DPE*" Then prenom2 = ""
'prenom1 = PartieGauche(prenom1, "DPE")
'prenom2 = PartieGauche(prenom2, "DPE")
'If prenom1 Like "*DPE*" Then prenom2 = ""
'prenom = prenom1 & prenom2
Call regnom(Phrase, Pattern, activite)
Else
Pattern = "(?:\s)(?:\w+\.?) {2,}(?:((?:[-A-Z]+ )+) +((?:[-A-Z]+ )+) +((?:[A-Z0-9]+ )+) +((?:[-A-Z0-9.]+ )+) +((?:[-A-Z0-9.]+ )+))"
activite = 0
Call regnom(Phrase, Pattern, activite)
nom2 = nom
End If
'Phrase = Application.Trim(Cells(lig, 1).Value)
' If inc = 2 Then nom = Mot
' If inc = 3 Then prenom1 = Mot
' If inc = 4 Then prenom2 = Mot
' If prenom2 Like "DPE*" Then prenom2 = ""
' prenom1 = PartieGauche(prenom1, "DPE")
' prenom2 = PartieGauche(prenom2, "DPE")
'If prenom1 Like "*DPE*" Then prenom2 = ""
End If
End If
If Cells(lig, 1).Value Like ">*" Then
Phrase2 = Cells(lig, 1).Value
Phrase2 = Replace(Phrase2, "SEGPA OPTION", "SEGPA OPTION")
Phrase2 = Replace(Phrase2, "SANS SPEC.", " SANS SPEC. ")
Phrase2 = Replace(Phrase2, " ST ", " ST ")
Phrase2 = Replace(Phrase2, " SEGPA ", " SEGPA ")
Phrase2 = Replace(Phrase2, " E.E.", " E.E.")
Phrase2 = Replace(Phrase2, " E.M.", " E.M.")
Phrase2 = Replace(Phrase2, " IEN ", " IEN ")
Phrase2 = Replace(Phrase2, " IEN TAMPON", " IEN TAMPON")
Phrase2 = Replace(Phrase2, " CLG", " CLG")
Phrase2 = Replace(Phrase2, "ENS.CL.ELE ", "ENS.CL.ELE ")
Phrase2 = Replace(Phrase2, "ENS.CL.MA ", "ENS.CL.MA ")
Phrase2 = Replace(Phrase2, ".MEN ", ".MEN ")
Phrase2 = Replace(Phrase2, "(sur", " (sur")
'Pattern = "(?:\>) (?:\w+) (?:\w+) +((?:[-A-Z0-9.]+ )+) +((?:[-A-Z0-9.]+ )+) +((?:[-A-Z0-9.]+ )+) +(?:\w+) (?:\w+) (?:\w+) +([0-9.]+)"
'Pattern = "(?:\>) (?:\w+) (?:\w+) (?:\w+) +((?:[-A-Z0-9.]+ )+) +((?:[-A-Z0-9.]+ )+) +((?:[-A-Z0-9.]+ )+) +((?:[-A-Z0-9.]+ )+) +((?:[-A-Z0-9.]+ )+) +([0-9.]+)"
'Pattern = "(?:\>) (?:\w+) (?:\w+) (?:\w+) +((?:[-a-zA-Z0-9.-é\(\)]+ )+) +((?:[-A-Z0-9.]+ )+) +((?:[-A-Z0-9.]+ )+)+((?:[-A-Z0-9.]+ )+) +((?:[-A-Z0-9.]+ )+) +([0-9.]+)"
Pattern = "(?:\>) (?:\w+) (?:\w+) (?:\w+) +((?:[-A-Za-z0-9.\(\)]+ )+) +((?:[-A-Za-z0-9.é\(\)]+ )+) +((?:[-A-Z0-9.]+ )+) +((?:[-A-Z0-9.]+ )+) +((?:[-A-Z0-9.]+ )+) +([0-9.]+)"
activite = 2
Call regnom(Phrase2, Pattern, activite)
End If
Next lig
Application.ScreenUpdating = True
End Sub
Function regnom(Phrase As String, Pattern As String, activite As Integer)
'Dim nom As String, prenom As String, code As String, commune As String
Dim Matches As Object
Set Matches = getRegExpMatches(Phrase, Pattern)
If Matches.Count > 0 Then
If activite = 1 Then
nom = Trim(Matches(0).SubMatches(0))
prenom = Trim(Matches(0).SubMatches(1))
code = Trim(Matches(0).SubMatches(2))
End If
If activite = 0 Then
nom = Trim(Matches(0).SubMatches(0))
prenom = Trim(Matches(0).SubMatches(1))
code = Trim(Matches(0).SubMatches(2))
ecole = Trim(Matches(0).SubMatches(3))
commune = Trim(Matches(0).SubMatches(4))
End If
If activite = 2 Then
ecoleaff = Trim(Matches(0).SubMatches(0))
communeaff = Trim(Matches(0).SubMatches(1))
posteaff = Trim(Matches(0).SubMatches(2))
speaff = Trim(Matches(0).SubMatches(3))
pointaff = Trim(Matches(0).SubMatches(5))
affectation = ecoleaff & communeaff & posteaff & speaff & pointaff
End If
Else
nom = "erreur pat"
End If
'Cell(1, 2).Value = Trim(Matches(0).SubMatches(0))
Application.ScreenUpdating = True
End Function
Function getRegExpMatches(Value As String, Pattern As String) As Object
Dim RegExp As Object
Set RegExp = CreateObject("VBScript.RegExp")
RegExp.Pattern = Pattern
'RegExp.Global = True
Set getRegExpMatches = RegExp.Execute(Value)
End Function |
Partager