
Sub NextRow()
ur = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To ur
txt = Cells(i, 1)
lng = Len(txt)
If lng > 25 Then
mx = lng / 25
For j = 1 To lng
a = a + 1
Cells(a, 5) = Mid(txt, j, 25)
j = j + 24
Next j
Else
a = a + 1
Cells(a, 5) = txt
End If
Next i
End Sub |
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("E25:E56,E88:E119")) Is Nothing Then Exit Sub
On Error Resume Next
Application.EnableEvents = False
Dim str As String
Dim start As Long
start = 34 '' MODIFICARE A PIACIMENTO l'unghezza stringa
str = Target.Value
If Len(str) > start Then
Cells(Target.Row, "E") = Mid(str, 1, start - 1) & "-"
End If
Application.EnableEvents = True
Cells(Target.Row + 1, "E") = Mid(str, start, Len(str))
End Sub
|
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("E25:E56,E88:E119")) Is Nothing Then Exit Sub
On Error Resume Next
Application.EnableEvents = False
Dim str As String, str1 As String
Dim start As Long
start = 34 '' MODIFICARE A PIACIMENTO l'unghezza stringa
str = Target.Value
If Len(str) > start Then
str1 = Mid(str, 1, InStrRev(Mid(str, 1, start - 1), " ", -1))
Cells(Target.Row, "E") = str1 & "-"
str = Application.Substitute(str, str1, "")
Else
Exit Sub
End If
Application.EnableEvents = True
Cells(Target.Row + 1, "E") = Trim(str)
End Sub |
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("E25:E56,E88:E119")) Is Nothing Then Exit Sub
On Error Resume Next
Application.EnableEvents = False
Dim str As String, str1 As String
Dim start As Long
start = 34 '' MODIFICARE A PIACIMENTO l'unghezza stringa
str = Target.Value
If Len(str) > start Then
str1 = Mid(str, 1, InStrRev(Mid(str, 1, start - 1), " ", -1))
Cells(Target.Row, "E") = str1 & "-"
str = Application.Substitute(str, str1, "")
Else
Application.EnableEvents = True
Exit Sub
End If
Application.EnableEvents = True
Cells(Target.Row + 1, "E") = Trim(str)
End Sub
|
