Option Explicit
Sub LimitedInput()
Dim s As String, t As String, sa, i As Long, j As Long, k As Long
Do
s = InputBox("Введите текст")
If s = "" Then Exit Do
sa = Split(s): t = ""
For j = LBound(sa) To UBound(sa)
If Len(t) + Len(sa(j)) < 30 Then
t = t & " " & sa(j)
Else
ActiveCell.Offset(i, 0) = Mid(t, 2)
i = i + 1: t = " " & sa(j)
End If
Next
If Len(t) > 0 Then
ActiveCell.Offset(i, 0) = Mid(t, 2)
i = i + 1
End If
Loop
End Sub
1 个回答