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
| Sub codage()
With Worksheets("ORIGINALE")
' .Unprotect Password:="popol"
Dim code As String
code = Worksheets("PROGRAMME").[D14].Value
Dim dl1 As Long
dl1 = 0
With Worksheets("ORIGINALE")
Dim r As Range
'16 correspond à la ligne de titre, pas la première ligne de valeur
For Each r In .Range("A16:A" & .Range("A" & Rows.Count).End(xlUp).Row)
If (r.Value <> " ") Then ' " " est un caractère espace, pas une chaîne vide
dl1 = dl1 + 1
If (r.Offset(0, 10).Value = " ") Then ' " " est un caractère espace, pas une chaîne vide
r.Offset(0, 10).Value = code & dl1
Exit For
End If
End If
Next r
End With
'.Protect Password:="popol"
End With
Sheets("PROGRAMME").Activate
End Sub |