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
| Sub RECOPIE()
Dim I As Long, J As Long
Dim nbLignes As Long 'nombre de lignes de la feuille de données
Dim Ligne As Long 'première ligne vide de l'onglet des médecins
Dim Feuille As String 'Nom de la feuille du médecin en cours
With Sheets("BASE")
nbLignes = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
For I = 2 To nbLignes
Feuille = GetNomFeuille(Range("A" & I)) 'en assumant que le nom du médecin est en colonne A
Ligne = Sheets(Feuille).Cells(Rows.Count, "A").End(xlUp).Row + 1 'première ligne vide
For J = 1 To 13
Sheets(Feuille).Cells(Ligne, J) = Sheets("BASE").Cells(I, J)
Next
Next
End Sub
Function GetNomFeuille(Nom As String) As String
Dim I As Long, nbLignes As Long
nbLignes = Sheets("Liste").Cells(Rows.Count, "A").End(xlUp).Row
For I = 1 To nbLignes
If Sheets("Liste").Range("A" & I) = Nom Then
GetNomFeuille = Sheets("Liste").Range("B" & I)
Exit Function
End If
Next
End Function |
Partager