mettere tutte le cartelle di lavoro che si desidera unire in una cartella del vostro computer. 
 2 
 Aprire una nuova cartella di lavoro in Excel. 
 
 3 
 Premere Alt + F11 . Si aprirà l'editor di Visual Basic. 
 4 
 Seleziona "Modulo " dal menu "Inserisci" . 
 5 
 Copia e incolla il seguente codice VB nella finestra di testo : 
 
 MergeAllWorkbooks sub () 
 
 Dim myPath As String , FilesInPath As String Dim 
 
 MyFiles () As String Dim 
 
 SourceRcount As Long , FNum Come lungo 
 
 Dim MyBook come libro di esercizi , BaseWks come manuale 
 
 Dim sourceRange come gamma , destrange come gamma 
 
 Dim rnum As Long , calc vel As Long 
 
 MyPath = " PATHHERE " 
 
 Destra ( MyPath , 1) < > " \\ " Allora 
 
 MyPath = MyPath & " \\ " 
 
 End If 
 
FilesInPath = Dir ( MyPath & " * . xl * " ) per
 FilesInPath = " " Allora 
 
 MsgBox " Nessun file trovato" 
 
 Exit Sub 
 
 End If 
 
 FNum = 0 
 
 fare mentre FilesInPath < > "" 
 
 FNum = FNum + 1 
 
 ReDim Preserve MyFiles ( 1 Per FNum ) 
 
 MyFiles ( FNum ) = FilesInPath 
 
FilesInPath = Dir ( ) per
 loop 
 
 Con Application 
 
 calc vel = . Calcolo 
 
 . calcolo = xlCalculationManual 
 
 . ScreenUpdating = False 
 
 . EnableEvents = False 
 
 terminare con 
 
BaseWks = Cartelle di lavoro . Add ( xlWBATWorksheet ) . fogli di lavoro ( 1 ) per
 rnum = 1 
 
 FNum > 0 Then 
 
FNum = LBound ( MyFiles ) A UBound ( MyFiles ) < br
 Set> mybook = Nothing 
 
 On Error Resume Next 
 
mybook = Workbooks.Open ( MyPath & MyFiles ( FNum ) ) per
 On Error GoTo 0 
 
 Se non MyBook è niente allora 
 
 On Error Resume Next 
 
mybook.Worksheets ( 1 ) per Set
sourceRange = Range ("A1 : . C1 " ) per
 End With 
 
 Se Err.Number > 0 Then 
 
 Err.Clear 
 
 sourceRange = Nothing Else 
 
 
 
 Se sourceRange.Columns.Count > = BaseWks.Columns.Count Poi 
 
 sourceRange = Nothing 
 
 End If End If 
 
 
 
 On Error GoTo 0 
 
 Se non sourceRange è niente allora 
 
 SourceRcount = sourceRange.Rows.Count 
 
 rnum + SourceRcount > = BaseWks.Rows.Count poi 
 
 MsgBox " non ci sono abbastanza righe del foglio di lavoro di destinazione. " 
 
 BaseWks.Columns.AutoFit 
 
 mybook.Close savechanges : = False 
 
 GoTo ExitTheSub 
 
 Else 
 
 sourceRange 
 
 BaseWks.Cells ( rnum , "A") . _ 
 
Resize ( . Rows.Count ) . Valore = MyFiles ( FNum ) per
 End With 
 
 destrange = BaseWks.Range ( " B " & rnum ) 
 
 Con sourceRange 
 
 destrange = destrange . _ 
 
Resize ( . Rows.Count , . Columns.Count ) per
 End With 
 
 destrange.Value = sourceRange.Value 
 
 rnum = rnum + SourceRcount 
 
 End If End If 
 
 
 
 mybook.Close savechanges : = False End If 
 
 
 
 Successivo 
 FNum 
 BaseWks.Columns.AutoFit 
 
 End If 
 
 ExitTheSub : . 
 
 Con Application 
 
 ScreenUpdating = True 
 
 EnableEvents = . vero 
 
 . Calcolo = calc vel 
 
 End With End Sub 
 
 
 6 
 Sostituire " PATHHERE " sulla linea 8 con il percorso della cartella con tutti i file della cartella di lavoro . Utilizza il modulo . "C: \\ Documenti \\ Folder1 \\ Cartella2 ... " 
 7 
 Premere Alt + Q per creare la cartella di lavoro di riepilogo 
 
              
sistemi © www.354353.com