Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao Icebrand,
la macro è quasi perfetta, l'unica cosa che manca è la somma totale delle colonne F e G, mentre attualmente viene fata solo sulla colonna C che non serve.
Sostituisci il codice precedente con:
'=========>>
Option Explicit
'--------->>
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet, destSH As Worksheet
Dim srcRng As Range, destRng As Range, headerRng As Range
Dim totRng As Range
Dim iRow As Long, jRow As Long, kRow As Long
Dim arrEscludere As Variant
Dim Res As Variant
Dim CalcMode As Long
Const sSheetName As String = "Riepilogo"
Const sEscludere As String = "Totale,Dati"
Const sIndirizoIntestazioni As String = "A3:H3"
On Error GoTo XIT
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Set WB = ActiveWorkbook
With WB
On Error Resume Next
Set destSH = .Sheets(sSheetName)
On Error GoTo 0
If Not destSH Is Nothing Then
destSH.UsedRange.Offset(1).ClearContents
Else
Set destSH = WB.Sheets.Add(Before:=.Sheets(1))
destSH.Name = sSheetName
End If
End With
arrEscludere = Split(sEscludere, ",")
For Each SH In WB.Sheets
With SH
Res = Application.Match(.Name, arrEscludere, 0)
If IsError(Res) And SH.Name <> destSH.Name Then
iRow = LastRow(SH)
Set headerRng = .Range(sIndirizoIntestazioni)
With headerRng
Set srcRng = .Offset(1).Resize(iRow - .Row - 1)
End With
jRow = LastRow(destSH)
If jRow = 0 Then
headerRng.Copy Destination:=destSH.Range("A1")
jRow = jRow + 1
End If
srcRng.Copy destSH.Range("A" & jRow + 1)
End If
End With
Next SH
With destSH
kRow = LastRow(destSH)
Set totRng = .Range("F" & kRow + 1).Resize(1, 2)
With totRng
.EntireRow.Cells(2).Value = "Totale"
.Value = "=Sum(" & "C2:C" & kRow & ")"
.NumberFormat = "$ #,##0.00"
End With
With .UsedRange
.Columns(1).NumberFormat = "dd/mm/yy"
.EntireColumn.AutoFit
End With
End With
XIT:
With Application
.Calculation = CalcMode
.ScreenUpdating = True
End With
End Sub
'--------->>
Public Function LastRow(SH As Worksheet, _
Optional Rng As Range)
If Rng Is Nothing Then
Set Rng = SH.Cells
End If
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
End Function
'<<=========
Potresti scaricare il mio file di prova Icebrand#3_210150405.xlsm a: **http://1drv.ms/19Ug1QL**
===
Regards,
Norman