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
|
Private Sub btn_valider_Click()
Dim i As Integer, j As Integer
Dim testNomFeuille As Boolean, testDate As Boolean, testTypeRecette As Boolean
Dim LigneDate As Integer
Dim colTypeRecette As Integer, colNbPatients As Integer, colNbCMU As Integer
Dim varSelectCase As Integer
Const NbLigne = 38 'Nombre de ligne servant à parcourir la premiere grille
Const NbColonne = 15
testNomFeuille = False
testDate = False
testTypeRecette = False
varSelectCase = 0
'test si le mois entrer correspond avec celui du classeur Excel et active la feuille correspondante au mois saisie
For i = 1 To Sheets.Count
If Sheets(i).Name = Et_Mois.Text Then
Sheets(i).Activate
testNomFeuille = True
End If
Next i
'si test reussi on parcours la grille pour trouver la ligne correspondant à la date saisi
If (testNomFeuille = True) Then
While (testDate = False)
For i = 1 To NbLigne
For j = 1 To NbColonne
If (Cells(i, j) = Val(Et_Date.Text)) Then
testDate = True
End If
Next j
Next i
LigneDate = i
Wend
If op_Cheques.Value = True Then
varSelectCase = 1
Else
If op_Virements.Value = True Then
varSelectCase = 2
Else
If op_CB.Value = True Then
varSelectCase = 3
Else
varSelectCase = 4
End If
End If
End If
Select Case varSelectCase
Case 1
'recherche de la colonne chèques
Do
For i = 1 To NbLigne
For j = 1 To NbColonne
Next j
Next i
Loop Until (Cells(i, j) = op_Cheques.Caption)
colTypeRecette = j
Case 2
'recherche de la colonne virements
Do
For i = 1 To NbLigne
For j = 1 To NbColonne
Next j
Next i
Loop Until (Cells(i, j) = op_Virements.Caption)
colTypeRecette = j
Case 3
'recherche de la colonne cb
Do
For i = 1 To NbLigne
For j = 1 To NbColonne
Next j
Next i
Loop Until (Cells(i, j) = op_CB.Caption)
colTypeRecette = j
Case 4
'recherche de la colonne espèces
Do
For i = 1 To NbLigne
For j = 1 To NbColonne
Next j
Next i
Loop Until (Cells(i, j) = op_Especes.Caption)
colTypeRecette = j
End Select
'recherche de la colonne où on doit saisir le nombre de patients
Do
For i = 1 To NbLigne
For j = 1 To NbColonne
Next j
Next i
Loop Until (Cells(i, j) = "Nb patients")
colNbPatients = j
'recherche de la colonne où on doit saisir le nombre de CMU
Do
For i = 1 To NbLigne
For j = 1 To NbColonne
Next j
Next i
Loop Until (Cells(i, j) = "Nb CMU")
colNbCMU = j
'Affectation des valeurs du userform à la feuille Excel
Cells(LigneDate, colTypeRecette) = Val(Et_Montant.Text)
Cells(LigneDate, colNbPatients) = Val(Et_Nbpatients.Text)
Cells(LigneDate, colNbCMU) = Val(Et_NbCMU.Text)
Else
MsgBox ("Saisissez correctement le mois, il doit correspondre au nom de votre feuille Excel")
End If
End Sub |
Partager