Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao Luca,
Spero di aver creato correttamente il link
Prova a sostituire il tuo codice con la seguente versione:
'=========>>
Option Explicit
'--------->>
Public Sub Tester()
Dim WB As Workbook
Dim srcSH As Worksheet, destSH As Worksheet
Dim srcRng As Range, destRng As Range
Dim arrIn As Variant, arrOut() As Variant
Dim arrTranspose() As Variant
Dim i As Long, j As Long, k As Long
Dim p As Long, q As Long
Dim iCtr As Long
Dim LRow As Long
Const sFoglio_Sorgente As String = "Margine" '<<=== Modifica
Const sFoglio_Destinazione As String = "Report" '<<=== Modifica
Set WB = ThisWorkbook
With WB
Set srcSH = .Sheets(sFoglio_Sorgente)
Set destSH = .Sheets(sFoglio_Destinazione)
End With
With srcSH
LRow = LastRow(srcSH, .Columns("A:A"))
Set srcRng = .Range("A1:BX" & LRow)
End With
Set destRng = destSH.Range("A2")
arrIn = srcRng.Value
For i = 2 To UBound(arrIn)
For j = 14 To UBound(arrIn, 2)
If arrIn(i, j) > 0 Then
iCtr = iCtr + 1
ReDim Preserve arrOut(1 To 15, 1 To iCtr)
For k = 1 To 13
arrOut(k, iCtr) = arrIn(i, k)
Next k
arrOut(14, iCtr) = arrIn(1, j)
arrOut(15, iCtr) = arrIn(i, j)
End If
Next j
Next i
ReDim arrTranspose(1 To iCtr, 1 To 15)
For p = 1 To UBound(arrOut)
For q = 1 To UBound(arrOut, 2)
arrTranspose(q, p) = arrOut(p, q)
Next q
Next p
Application.ScreenUpdating = False
With destRng
.CurrentRegion.ClearContents
.Resize(iCtr, 15).Value = arrTranspose
.CurrentRegion.EntireColumn.AutoFit
End With
Application.ScreenUpdating = True
Call MsgBox( _
Prompt:="Fatto", _
Buttons:=vbInformation, _
Title:="REPORT")
End Sub
'--------->>
Public Function LastRow(SH As Worksheet, _
Optional Rng As Range, _
Optional minRow As Long = 1, _
Optional sPassword As String)
Dim bProtected As Boolean
With SH
If Rng Is Nothing Then
Set Rng = .Cells
End If
bProtected = .ProtectContents = True
If bProtected Then
.Unprotect Password:=sPassword
End If
End With
On Error Resume Next
LastRow = Rng.Find(What:="*", _
after:=Rng.Cells(1), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
If LastRow < minRow Then
LastRow = minRow
End If
If bProtected Then
SH.Protect Password:=sPassword, _
UserInterfaceOnly:=True
End If
End Function
'<<=========
Eseguendo questo codice, ottengo un report di 102.967 righe e 76 colonne. Nota che, date le dimensioni del file, il completamento del codice richiederà circa due minuti.
Potresti scaricare il mio file di prova Luca20191029.xlsb
===
Regards,
Norman