Hi everyone. I have a macro (see below) that takes two code-defined worksheets from two workbooks and compares the data, colour highlighting any differences between cells in both worksheets.
However, what I would like to do is have this changed so that a popup window appears when the macro is run, prompting the user to select one range of data and then select a second set, then go on and have those selections compared. If this is not possible then perhaps the user could define which sheets/books are to be compared somehow (dropdown list, manually clicking?) rather than having to define them first in the code.
Any help much appreciated,
Nick, Cambridge, England
Sub Compare_Sheets()
Set From_WS = Workbooks( "Book1").Worksheets("Sheet1")
Set To_WS = Workbooks("Book2").Worksheets("Sheet2")
Total_Rows = From_WS. Cells(1, 1). CurrentRegion. Rows. Count
Total_Columns = To_WS. Cells(1, 1). CurrentRegion. Columns. Count
For Rows_Counter = 1 To Total_Rows
For Column_Counter = 1 To Total_Columns
If Trim( LCase( From_WS. Cells( Rows_Counter, Column_Counter). Value)) <> _
Trim( LCase( To_WS. Cells( Rows_Counter, Column_Counter). Value)) Then
From_WS.Cells( Rows_Counter, Column_Counter). Interior. ColorIndex = 4
To_WS.Cells( Rows_Counter, Column_Counter). Interior.ColorIndex = 5
End If
Next Column_Counter
Next Rows_Counter
End Sub
Bookmarks