Sub posiziona2()
Dim sh1 As Worksheet: Set sh1 = Worksheets("Scheda")
Dim sh2 As Worksheet: Set sh2 = Worksheets("Servizio")
Dim D As String
Dim F As Long
For F = 1 To 7
D = Len(sh2.Cells(1, F))
If Right(sh2.Cells(1, F), 2) = "AB" Then
sh1.Cells(23, 1).End(xlDown).Offset(1, 0).Value = Mid(sh2.Cells(1, F), 1, D - 2)
sh1.Cells(23, 1).End(xlDown).Offset(0, 1).Value = Mid(sh2.Cells(1, F), D - 1, 1)
sh1.Cells(23, 1).End(xlDown).Offset(1, 0).Value = Mid(sh2.Cells(1, F), 1, D - 2)
sh1.Cells(23, 1).End(xlDown).Offset(0, 1).Value = Right(sh2.Cells(1, F), 1)
Else
sh1.Cells(23, 1).End(xlDown).Offset(1).Value = sh2.Cells(1, F).Value
End If
Next
End Sub
secondo codice
Sub posiziona3()
Dim sh1 As Worksheet: Set sh1 = Worksheets("Scheda")
Dim sh2 As Worksheet: Set sh2 = Worksheets("Servizio")
Dim D As String
Dim F As Long
For F = 1 To 7
D = Len(sh2.Cells(1, F))
If Right(sh2.Cells(1, F), 2) = "AB" Then
sh1.Cells(31, 2).End(xlDown).Offset(1, 0).Value = Mid(sh2.Cells(1, F), 1, D - 2)
sh1.Cells(31, 2).End(xlDown).Offset(0, 1).Value = Mid(sh2.Cells(1, F), D - 1, 1)
sh1.Cells(31, 2).End(xlDown).Offset(1, 0).Value = Mid(sh2.Cells(1, F), 1, D - 2)
sh1.Cells(31, 2).End(xlDown).Offset(0, 1).Value = Right(sh2.Cells(1, F), 1)
Else
sh1.Cells(31, 2).End(xlDown).Offset(1).Value = sh2.Cells(1, F).Value
End If
Next
End Sub
|