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
| 'on génére les différentes variables qui nous permettront de savoir sur quelle ligne nous devons écrire
Dim ii As Integer
Dim line20 As Integer
Dim i20 As Integer
Dim final As Boolean
final = False
ii = 6
Dim line50 As Integer
Dim i50 As Integer
Dim line90 As Integer
Dim i90 As Integer
Dim line130 As Integer
Dim i130 As Integer
Dim line206 As Integer
Dim i206 As Integer
Dim line1000 As Integer
Dim i1000 As Integer
Dim line3000 As Integer
Dim i3000 As Integer
Dim line515 As Integer
Dim i515 As Integer
Dim lineinf As Integer
Dim iinf As Integer
'démarrage de la première boucle
While final = False
'on vérifie si le montant est compris entre 0 et 20000 si c'est le cas on execute la boucle sinon on passe à la suivante
'l'utilisateur à écrit une année dans la textbox1 (txt1)
If 0 <= wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("AN" & ii).Value < 20000 Then
'on recherche la zone ou le texte comrpis entre 0 et 20000 est écrit
Cells.Select
Selection.Find(What:="Montant du marché : [0 ; 20 000[ Hors Taxes", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
'on définit la zone ou y a le texte comme point de départ
line20 = ActiveCell.Row
'on se place sur la ligne du dessous
i20 = line20 + 1
'on inscrit les informations nécéssaire
wb4.Worksheets("Feuil1").Range("B" & i20).Value = wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("AJ" & ii).Value
wb4.Worksheets("Feuil1").Range("C" & i20).Value = wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("AK" & ii).Value
wb4.Worksheets("Feuil1").Range("D" & i20).Value = wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("AM" & ii).Value
wb4.Worksheets("Feuil1").Range("E" & i20).Value = wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("AN" & ii).Value
If wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("D" & ii).Value = "" Then
wb4.Worksheets("Feuil1").Range("A" & i20).Value = wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("C" & ii).Value
Else
wb4.Worksheets("Feuil1").Range("A" & i20).Value = wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("D" & ii).Value
End If
'on insère une nouvelle ligne afin de laisser une ligne vierge sous le titre pour pouvoir écrire le prochain contrat
Rows(i20 + 1 & ":" & i20 + 1).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
'on incrémente ii sur la feuille base de données afin de passer à la linge suivante
ii = ii + 1
If wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("AJ" & ii).Value = "" Then
final = True
End If
'on met fin à la boucle
Else
ii = ii + 1
End If
Wend
'----------------------------------------------------------------------------
final = False
While final = False
If 20000 <= wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("AN" & ii).Value < 50000 Then
Cells.Select
Selection.Find(What:="Montant du marché : [20 000 ; 50 000[ Hors Taxes", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
line50 = ActiveCell.Row
i50 = line50 + 1
wb4.Worksheets("Feuil1").Range("B" & i50).Value = wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("AJ" & ii).Value
wb4.Worksheets("Feuil1").Range("C" & i50).Value = wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("AK" & ii).Value
wb4.Worksheets("Feuil1").Range("D" & i50).Value = wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("AM" & ii).Value
wb4.Worksheets("Feuil1").Range("E" & i50).Value = wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("AN" & ii).Value
If wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("D" & ii).Value = "" Then
wb4.Worksheets("Feuil1").Range("A" & i50).Value = wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("C" & ii).Value
Else
wb4.Worksheets("Feuil1").Range("A" & i50).Value = wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("D" & ii).Value
End If
Rows(i50 + 1 & ":" & i50 + 1).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
ii = ii + 1
If wb.Worksheets("Formations en " & FRM_SECA.txt1).Range("AJ" & ii).Value = "" Then
final = True
End If
Else
ii = ii + 1
End If
Wend |
Partager