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
| Sub AfficherConsultations()
Dim debut As String, fin As String, nom As String, heure As String, jour As String
Dim c As Range, c2 As Range, c3 As Range, plage As Range
Dim colonne As Integer, colonne2 As Integer, ligne As Integer, nbrConsultations As Integer, indx As Integer, HR As Integer, JR As Integer
debut = InputBox("Saisir la date de début")
If Not IsDate(debut) Then
MsgBox "Ce n'est pas un format date"
Else
If debut <> Format(debut, "dd/mm/yyyy") Then
MsgBox "le format doit être jj/mm/aaaa"
End If
End If
fin = InputBox("Saisir la date de fin")
If Not IsDate(fin) Then
MsgBox "Ce n'est pas un format date"
Else
If fin <> Format(fin, "dd/mm/yyyy") Then
MsgBox "le format doit être jj/mm/aaaa"
End If
End If
nom = InputBox("Veuillez entrer le nom de la personne concernée par votre recherche")
If nom = "" Then
MsgBox "Vous n'avez entré aucun nom"
End If
For Each c In Range("B1:XFD1")
If c = debut Then
ligne = c.Row + 1
colonne = c.Column
End If
Next c
For Each c2 In Range("B1:XFD1")
If c2 = fin Then
colonne2 = c2.Column
End If
Next c2
Set plage = Range(Cells(ligne, colonne), Cells(26, colonne2))
nbrConsultations = Application.CountIf(plage, nom & "*")
MsgBox nom & " a effectué " & CStr(nbrConsultations) & " consultations entre le " & debut & " et le " & fin
For Each c3 In plage.SpecialCells(xlCellTypeConstants)
If InStr(Trim(UCase(c3.Value)), Trim(UCase(nom))) Then
HR = c3.Row
JR = c3.Column
heure = Format(Cells(HR, 1).Value, "hh:mm")
jour = Cells(1, JR).Value
indx = indx + 1
MsgBox "Jour du rendez-vous " & CStr(indx) & " le " & jour & ", à " & heure
End If
Next c3
End Sub |
Partager