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
| Sub Transfert()
'
' Lecture du nom à classer
Sheets("Feuil1").Select
Nom = Cells(1, 2)
Region = Cells(2, 2)
numero = Cells(3, 2)
' vérification
MsgBox ("Nom : " & Nom & Chr(13) & _
"Région : " & Region & Chr(13) & _
"Numéro : " & numero & Chr(13))
' Boucle de recherche de la région
Region_Col = 0
For Com = 1 To 255 Step 2
If Cells(10, Com) = Region Then Region_Col = Com
Next
' Test de controle
If Region_Col = 0 Then
MsgBox ("ATTENTION la région : " & Region & " n'existe pas dans le tableau")
Exit Sub
End If
' Boucle de recherche de la première ligne disponible
Lig = 10
Do
Lig = Lig + 1
If Cells(Lig, Region_Col) = "" Then
' Ecriture
Cells(Lig, Region_Col) = Nom
Cells(Lig, Region_Col + 1) = numero
' RAZ
Cells(1, 2) = ""
Cells(2, 2) = ""
Cells(3, 2) = ""
' FIN
Exit Do
End If
Loop
End Sub |
Partager