Sub Compare_2_fichiers()
NWC = ThisWorkbook.Name 'Name Workbook Comparaison
'Stop
On Error Resume Next
Cells.Clear
Dim NW1S(1000), NW2S(1000)
FirstLig = 3
For i = 1 To 2
ActiveWindow.ActivateNext
'Affiche toutes les feuilles Classeur1
nc = ActiveWorkbook.Sheets.Count
For N = 1 To nc
Sheets(N).Visible = True
Next
NW1 = ActiveWorkbook.Name
NW1P = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
ActiveWindow.ActivateNext
'Affiche toutes les feuilles Classeur2
nc = ActiveWorkbook.Sheets.Count
For N = 1 To nc
Sheets(N).Visible = True
Next
NW2 = ActiveWorkbook.Name
NW2P = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
ActiveWindow.ActivateNext
If ActiveWorkbook.Name = NWC Then GoTo suite Else MsgBox "Vous devez fermer les fichiers non utiles": End
Next
suite:
'MsgBox "Comparaison " & NW1 & " et " & NW2
Cells(2, 1) = "Comparaison " & NW1 & " et " & NW2
Cells(3, 1) = NW1P: Cells(3, 2) = NW1
Cells(3, 3) = NW2P: Cells(3, 4) = NW2
For i = 1 To Workbooks(NW1).Worksheets.Count
NW1S(i) = Workbooks(NW1).Worksheets(i).Name
Set myRange = Workbooks(NW1).Worksheets(i).Range("A1:IU65536").SpecialCells(xlCellTypeFormulas, xlNumbers)
t = Application.WorksheetFunction.Sum(myRange)
Cells(i + FirstLig, 1) = NW1S(i): Cells(i + FirstLig, 2) = t
Next
For i = 1 To Workbooks(NW2).Worksheets.Count
NW2S(i) = Workbooks(NW2).Worksheets(i).Name
Set myRange = Workbooks(NW2).Worksheets(i).Range("A1:IU65536")
t = Application.WorksheetFunction.Sum(myRange)
Cells(i + FirstLig, 3) = NW2S(i): Cells(i + FirstLig, 4) = t
Next
End Sub