Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao Alex,
https://drive.google.com/file/d/1v9qMmfNgGnjN4BNUIdvZWu1BBGRy8D7k/view?usp=sharing
Eccolo, grazie!
Sostituisci il tuo codice con la seguente versione:
'=========>>
Option Explicit
'--------->>
Public Sub Copia_dati()
Dim WB As Workbook
Dim srcSH As Worksheet
Dim destSH1 As Worksheet, destSH2 As Worksheet
Dim destSH3 As Worksheet, destSH4 As Worksheet
Dim LRow As Long
Const sFoglio_Sorgente As String = "Copia dati"
Const sFoglio1 As String = "Segni puri Aggio BVS"
Const sFoglio2 As String = "Gol"
Const sFoglio3 As String = "Fattore 3D varie"
Const sFoglio4 As String = "Quote"
On Error GoTo XIT
Application.ScreenUpdating = False
Set WB = ThisWorkbook
With WB
Set srcSH = .Sheets(sFoglio_Sorgente)
Set destSH1 = .Sheets(sFoglio1)
Set destSH2 = .Sheets(sFoglio2)
Set destSH3 = .Sheets(sFoglio3)
Set destSH4 = .Sheets(sFoglio4)
End With
With destSH1
LRow = LastRow(SH:=destSH1, rng:=.Columns("B:B"), minRow:=4)
srcSH.Range("B2").Copy Destination:=.Range("B" & LRow + 1)
srcSH.Range("B6:D6").Copy Destination:=.Range("E" & LRow + 1)
srcSH.Range("B8:D8").Copy Destination:=.Range("H" & LRow + 1)
srcSH.Range("B11:D11").Copy Destination:=.Range("K" & LRow + 1)
srcSH.Range("B14:D14").Copy Destination:=.Range("N" & LRow + 1)
srcSH.Range("B16").Copy Destination:=.Range("Q" & LRow + 1)
srcSH.Range("B58:E58").Copy Destination:=.Range("R" & LRow + 1)
End With
With destSH2
LRow = LastRow(SH:=destSH2, rng:=.Columns("B:B"), minRow:=4)
srcSH.Range("B2").Copy Destination:=.Range("B" & LRow + 1)
srcSH.Range("B21:C21").Copy Destination:=.Range("C" & LRow + 1)
srcSH.Range("B23:C23").Copy Destination:=.Range("E" & LRow + 1)
srcSH.Range("B25:C25").Copy Destination:=.Range("G" & LRow + 1)
srcSH.Range("B27:C27").Copy Destination:=.Range("I" & LRow + 1)
srcSH.Range("B29:C29").Copy Destination:=.Range("K" & LRow + 1)
srcSH.Range("B31:C31").Copy Destination:=.Range("M" & LRow + 1)
srcSH.Range("B33:C33").Copy Destination:=.Range("O" & LRow + 1)
srcSH.Range("B35:C35").Copy Destination:=.Range("Q" & LRow + 1)
srcSH.Range("B37:C37").Copy Destination:=.Range("S" & LRow + 1)
srcSH.Range("B39:C39").Copy Destination:=.Range("U" & LRow + 1)
srcSH.Range("B41:C41").Copy Destination:=.Range("W" & LRow + 1)
srcSH.Range("B43:C43").Copy Destination:=.Range("Y" & LRow + 1)
End With
With destSH3
LRow = LastRow(SH:=destSH3, rng:=.Columns("B:B"), minRow:=4)
srcSH.Range("B2").Copy Destination:=.Range("B" & LRow + 1)
srcSH.Range("B48:E48").Copy Destination:=.Range("C" & LRow + 1)
srcSH.Range("B53:E53").Copy Destination:=.Range("G" & LRow + 1)
End With
With destSH4
LRow = LastRow(SH:=destSH4, rng:=.Columns("B:B"), minRow:=4)
srcSH.Range("B2").Copy Destination:=.Range("B" & LRow + 1)
srcSH.Range("B76:C76").Copy Destination:=.Range("C" & LRow + 1)
srcSH.Range("B78:C78").Copy Destination:=.Range("E" & LRow + 1)
srcSH.Range("B80:C80").Copy Destination:=.Range("G" & LRow + 1)
srcSH.Range("B82").Copy Destination:=.Range("I" & LRow + 1)
srcSH.Range("B84").Copy Destination:=.Range("J" & LRow + 1)
srcSH.Range("B86").Copy Destination:=.Range("K" & LRow + 1)
srcSH.Range("B88:C88").Copy Destination:=.Range("L" & LRow + 1)
srcSH.Range("B90:C90").Copy Destination:=.Range("N" & LRow + 1)
End With
Call MsgBox( _
Prompt:="Finito", _
Buttons:=vbInformation, _
Title:="REPORT")
XIT:
Application.ScreenUpdating = False
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
Application.ScreenUpdating = False
.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
Application.ScreenUpdating = True
End Function
'<<=========
Potresti scaricare il mio file di prova Alex20180728.xlsm
===
Regards,
Norman