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
| Option Explicit
Sub Dat_nais()
Dim pl, nbc, nbr As Integer
Dim pc As Byte
Dim dn, dn1, dn2 As String
' 1ère ligne de données (modifier si différente de 2)
pl = 2
' colonne contenant les données (modifier si différente de 1, 1 étant = "A")
pc = 1
nbr = 0
Debut: dn = Cells(pl, pc)
If dn = "" Then MsgBox "Traitement terminé, " & nbr & " ligne(s)modifiée(s).", _ vbOKOnly + vbInformation + vbApplicationModal, "Information"
Exit Sub
Else nbc = Len(dn)
If nbc > 10 Then
dn1 = Left(dn, 10)
dn2 = Right(dn, 10)
If dn1 < dn2 Then
Cells(pl, pc) = dn1
Else Cells(pl, pc) = dn2
End If
nbr = nbr + 1
pl = pl + 1
GoTo Debut
Else pl = pl + 1
GoTo Debut
End If
End If
End Sub |
Partager