Ciao Cristian,
Data la presenza di 5000 righe, se volessi evitare l'uso delle formule, potresti provare qualcosa del genere:
- Alt+F11 per aprire l'editor di VBA
- Alt+IM per inserire un nuovo modulo di codice
- Nel nuovo modulo vuoto, incolla il seguente codice:
'=========>>
Option Explicit
'--------->>
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim srcRng As Range, destRng As Range
Dim arrIn As Variant, arrOut() As Variant
Dim iRows As Long, LRow As Long
Dim i As Long, j As Long, k As Long
Dim ictr As Long
Dim CalcMode As Long
Const sFoglio As String = "Foglio1" '<<=== Modifica
Const iRighePerBloccoDati As Long = 9 '<<=== Modifica
Const iPrimaRigaDati As Long = 2 '<<=== Modifica
Const iRigheVuoteTraBlocchiDati As Long =1 '<<=== Modifica
Const sDestinazione As String = "C2" '<<=== Modifica
Set WB = ThisWorkbook
Set SH = WB.Sheets(sFoglio)
iRows = iRighePerBloccoDati _
+ iRigheVuoteTraBlocchiDati
With SH
LRow = LastRow(SH, .Columns("A:A"))
Set srcRng = .Range("A" & iPrimaRigaDati & ":A" & LRow)
Set destRng = .Range(sDestinazione)
End With
arrIn = srcRng.Value
ReDim arrOut(1 To (LRow - iPrimaRigaDati) / _
iRows, 1 To iRighePerBloccoDati)
For i = 1 To UBound(arrIn) Step iRows
ictr = ictr + 1
For j = 1 To iRighePerBloccoDati
arrOut(ictr, j) = arrIn(i + j - 1, 1)
Next j
Next i
On Error GoTo XIT
Application.ScreenUpdating = False
destRng.Resize(ictr, iRighePerBloccoDati).Value = arrOut
Call MsgBox( _
Prompt:="Fatto!", _
Buttons:=vbInformation, _
Title:="REPORT")
XIT:
Application.ScreenUpdating = True
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
'<<=========
- Alt+Q per chiudere l'editor di VBA e tornare a Excel
- Salva il file con l’estensione xlsm
- Alt+F8 per aprire la finestra di gestione delle macro
- Seleziona Tester
- Esegui
===
Regards,
Norman
