
Option Explicit
Sub trasponiDate()
Dim i As Long
Dim URiga As Long, PRiga As Long
Dim verUriga As Long, verData As Long
verUriga = 0
verData = 0
Application.ScreenUpdating = False
For i = Cells(Rows.Count, 2).End(xlUp).Row To 1 Step -1
If IsDate(Cells(i, 2)) Then
If verUriga = 0 Then
URiga = i
verUriga = 1
verData = 0
End If
Else
If verData = 0 Then
PRiga = i + 1
Range("B" & PRiga & ":B" & URiga).Select
Application.CutCopyMode = False
Selection.Copy
Range("C" & i).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
verUriga = 0
verData = 1
Rows(PRiga & ":" & URiga).Select
Selection.Delete Shift:=xlUp
End If
End If
Next i
Application.ScreenUpdating = True
Range("A1").Select
End Sub
|
Option Explicit
Sub RifCodice()
Sheets("foglio2").Select
Dim i As Long, o As Long
Dim Codice2 As String
Dim Codice1 As String
Application.ScreenUpdating = False
Application.EnableEvents = False
Range("F6:AZ1000") = ""
For i = 6 To Cells(Rows.Count, 3).End(xlUp).Row
Codice2 = Cells(i, 3)
For o = 1 To Sheets("foglio1").Cells(Rows.Count, 2).End(xlUp).Row
Codice1 = Sheets("foglio1").Cells(o, 2)
If InStr(1, Codice1, "(") > 0 Then
If Codice2 = Mid(Codice1, InStr(1, Codice1, "(") + 1, 10) Then
Sheets("foglio1").Range("C" & o + 2 & ":AZ" & o + 2).Copy
Cells(i, 7).Select
ActiveSheet.Paste
Cells(i, 6) = Application.CountA(Range("G" & i & ":AZ" & i))
Application.CutCopyMode = False
End If
End If
Next o
Next i
Range("H5").Select
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
|
Option Explicit
Sub CopiaRighe()
Dim i As Long
For i = Cells(Rows.Count, 2).End(xlUp).Row To 4 Step -1
If Cells(i, 2).Value = "Data" Then
Range(Cells(i, 2), Cells(i, 45)).Select
Selection.Cut
Cells(i - 2, 4).Select
ActiveSheet.Paste
'''''''
Cells(i - 1, 2).Select
Selection.Cut
Cells(i - 2, 3).Select
ActiveSheet.Paste
End If
If Cells(i, 2) = "" Then Rows(i & ":" & i).Delete Shift:=xlUp
Next i
End Sub
|
Option Explicit
Sub trasponiDate()
Dim i As Long
Dim URiga As Long, PRiga As Long
Dim verUriga As Long, verData As Long
verUriga = 0
verData = 0
Application.ScreenUpdating = False
For i = Cells(Rows.Count, 2).End(xlUp).Row To 1 Step -1
If IsDate(Cells(i, 2)) Then
If verUriga = 0 Then
URiga = i
verUriga = 1
verData = 0
End If
Else
If verData = 0 Then
PRiga = i + 1
Range("B" & PRiga & ":B" & URiga).Select
Application.CutCopyMode = False
Selection.Copy
Range("C" & i).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
verUriga = 0
verData = 1
Rows(PRiga & ":" & URiga).Select
Selection.Delete Shift:=xlUp
End If
End If
Next i
Call CopiaRighe '' inserito richiamo alla sub CopiaRighe
Application.ScreenUpdating = True
Range("A1").Select
End Sub
Sub CopiaRighe()
Dim i As Long
For i = Cells(Rows.Count, 2).End(xlUp).Row To 4 Step -1
If Cells(i, 2).Value = "Data" Then
Range(Cells(i, 2), Cells(i, 45)).Select
Selection.Cut
Cells(i - 2, 6).Select ''cambiato valore colonna
ActiveSheet.Paste
'''''''
Cells(i - 1, 2).Select
Selection.Cut
Cells(i - 2, 4).Select ''cambiato valore colonna
ActiveSheet.Paste
End If
If Cells(i, 2) = "" Then Rows(i & ":" & i).Delete Shift:=xlUp
Next i
End Sub
|
