Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao FabioPZ,
se le intestazioni di colonna sono sempre e solo, in tutti i fogli, nella riga 1 allora questa potrebbe fare al caso tuo.
Da incollare nel modulo Visual Basic "ThisWorkbook".
' ThisWorkbook - Workbook
'
Option Explicit
Private Function GetWbkByName(ByVal Name As String) As Excel.Workbook
On Error Resume Next
Set GetWbkByName = Application.Workbooks(Name)
End Function
Private Sub Workbook_Open()
'
' Cambiare in base alle proprie impostazioni
'
Const cstrPath = "" ' Cambiare se il percorso è diverso da quello di destinazione
Const cstrFilename = "Cartella da cui copiare.xls"
Const cstrShDest = "Foglio1" ' Nome del foglio di destinazione
Dim wbk As Excel.Workbook
Dim sh As Excel.Worksheet
Dim shOut As Excel.Worksheet
Dim rng As Excel.Range
Dim strPath As String
Dim strFilename As String
Dim lngOffset As Long
Dim blnClose As Boolean
If MsgBox("Vuoi aggiornare i dati?" _
, vbQuestion + vbYesNo _
) <> vbYes Then
Exit Sub
End If
If Len(strPath) = 0 Then strPath = Me.Path
If Right$(strPath, 1) <> "" Then strPath = strPath & ""
strFilename = cstrFilename
Set wbk = GetWbkByName(strFilename)
If wbk Is Nothing Then
blnClose = True
Set wbk = Application.Workbooks.Open(strPath & strFilename)
End If
Set shOut = Me.Worksheets(cstrShDest)
With shOut
.Cells.Clear
Set rng = .Cells(1, 1)
End With
For Each sh In wbk.Worksheets
With sh.UsedRange
With .Offset(lngOffset).Resize(.Rows.Count - lngOffset)
.Copy rng
Set rng = rng.Offset(.Rows.Count)
End With
End With
If lngOffset = 0 Then lngOffset = 1
Next
If blnClose Then wbk.Close False
Set rng = Nothing
Set shOut = Nothing
Set sh = Nothing
Set wbk = Nothing
End Sub