Sub Copier_Coller()
[Source].Offset(7) = [Source].Value
With [Source].Offset(7).Resize([Source].Rows.Count)
.AutoFill .Resize(1000 * .Rows.Count)
End With
End Sub
Sub SuperposerItemsChaine_Avec_RegExp()
Dim dur, o As Object, tablo, i&, t$
dur = Timer
Set o = CreateObject("VBScript.RegExp")
o.IgnoreCase = False
o.Global = True
o.Pattern = "( )([A-Z]|[ÀÁÂÃÄÅÒÓÔÕÖØÈÉÊËÌÍÎÏÙÚÛÜÑÇ])" 'un espace suivi d'une lettre majuscule. Tient compte des majuscules diacritées
With [Source].Offset(7).Resize(1000 * [Source].Rows.Count)
tablo = .Value 'matrice, plus rapide
For i = 1 To UBound(tablo)
t = Application.Trim(Replace(tablo(i, 1), vbLf, " "))
tablo(i, 1) = o.Replace(t, "$1" & vbLf & "$2")
Next
.Value = tablo
End With
MsgBox "Durée " & Format(Timer - dur, "0.00 \sec")
End Sub
Sub SuperposerItemsChaine_Sans_RegExp()
Dim dur, majuscules$, tablo, i&, t$, j%
dur = Timer
majuscules = "ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÒÓÔÕÖØÈÉÊËÌÍÎÏÙÚÛÜÑÇ"
With [Source].Offset(7).Resize(1000 * [Source].Rows.Count)
tablo = .Value 'matrice, plus rapide
For i = 1 To UBound(tablo)
t = " " & Application.Trim(Replace(tablo(i, 1), vbLf, " "))
For j = Len(t) To 2 Step -1
If InStr(majuscules, Mid(t, j, 1)) And Mid(t, j - 1, 1) = " " Then t = Left(t, j - 2) & vbLf & Mid(t, j): j = j - 1
Next j
tablo(i, 1) = Mid(t, 2)
Next i
.Value = tablo
End With
MsgBox "Durée " & Format(Timer - dur, "0.00 \sec")
End Sub