Questa macro consente di mettere a confronto le formule presenti in due fogli di calcolo di Excel, riporterà : il nome del foglio, la cella e la formula prima e dopo per ogni cella con formula differente.
La procedura di confronto fra i fogli.
Sub Confronta()
Set Fc =
Sheets(1)
CancellaPrima
Riga = 10
fOld =
Application.GetOpenFilename("File Vecchio (*.xls), *.xls")
fNew =
Application.GetOpenFilename("File Nuovo (*.xls), *.xls")
If (fOld <> falso And fNew <> falso)
Then
Set WbOld = Workbooks.
Open(FileName:=fOld, UpdateLinks:=0)
Set WbNew = Workbooks.
Open(FileName:=fNew, UpdateLinks:=0)
Fc.Activate
For Each FlNew
In WbNew.
Worksheets
'FlNew.Activate
Set Ur = FlNew.
UsedRange
For Each CeNew
In Ur
Set CeOld = WbOld.
Sheets(FlNew.Name).
Range(CeNew.
Address)
Modificata = False
If (
Mid(CeNew.
Formula, 1, 1) = "=" And CeNew.
Formula <> CeOld.
Formula)
Then
Fc.
Cells(Riga, 3) = FlNew.Name
Fc.
Cells(Riga, 4) = CeNew.
Address(RowAbsolute:=False, ColumnAbsolute:=False)
Fc.
Cells(Riga, 5) = CeNew.
Formula
Fc.
Cells(Riga, 6) = CeOld.
Formula
Modificata = True
End If
If (Modificata)
Then Riga = Riga + 1
Next CeNew
Next FlNew
WbNew.
Close savechanges:=False
WbOld.
Close savechanges:=False
End If
End Sub
La procedura che cancella il foglio di eventuali differenze già trovate.