Bonjour Lapou, Berty, le Forum
Et oui tu te fais gronder car ton sujet n'est pas vraiment "XLD" compliant... En suite j'ai aussi du mal à interpréter ta demande...
Enfin pour faire avncer le "schmilblick", imaginons que dans la feuille active tu aies ceci dans les cellules de A1 à A10 :
DCOM1
TCOM2
DCOM3
DCOM4
DCON5
TCAM1
DCAN2
DCOM1
DCOM9
TCAN1
Et que tu veuilles donc retourner en face de chaque ligne :
Colonne B = "DEUG"
Colonne C = "Communication"
Colonne D = "Methodo"
Colonne E = "1er année, 1er semestre"
Si bien entendu il y a "DCOM1" inscrit dans la colonne "A"....
Voici un Code VBA qui le fait (à placer dans un module standard) :
Option Explicit
Const D As String = "DEUG"
Const T As String = "TOTO"
Const CO As String = "Communication"
Const CA As String = "Carnaval"
Const M As String = "Methodo"
Const N As String = "Neptune"
Const UN As String = "1er année, 1er semestre"
Const DE As String = "1em année, 2em semestre"
Sub Test()
Dim Cell As Range, Plage As Range
Dim i As Integer
Set Plage = ActiveSheet.Range("A1:A50")
For Each Cell In Plage
For i = 1 To Len(Cell.Text)
Select Case i
Case 1
If Left(Cell.Text, 1) = "D" Then Cell.Offset(0, 1) = D
If Left(Cell.Text, 1) = "T" Then Cell.Offset(0, 1) = T
Case 2
If Mid(Cell.Text, 2, 2) = "CO" Then Cell.Offset(0, 2) = CO
If Mid(Cell.Text, 2, 2) = "CA" Then Cell.Offset(0, 2) = CA
Case 4
If Mid(Cell.Text, 4, 1) = "M" Then Cell.Offset(0, 3) = M
If Mid(Cell.Text, 4, 1) = "N" Then Cell.Offset(0, 3) = N
Case 5
If Mid(Cell.Text, 5, 1) = "1" Then Cell.Offset(0, 4) = UN
If Mid(Cell.Text, 5, 1) = "2" Then Cell.Offset(0, 4) = DE
End Select
Next i
Next Cell
End Sub
Mais est-ce donc ce dont tu as besoin, je n'en suis pas vraiment sûr...
Bon Aprèm
@+Thierry