ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Two Ranges, Spot Different Values (https://www.excelbanter.com/excel-programming/382352-two-ranges-spot-different-values.html)

Neal Zimm

Two Ranges, Spot Different Values
 
I have two ranges in the same sheet where I want to know
if a cell's value is different between the "original" and the copy.
The "in development" code below works but takes more than
a few seconds to run.

I'll be working thru ignoring some cells with formulas.
I will be able to get the row/col values for the two ranges
with their begining/ending row/col numbers.

I'm not yet familiar with 'specialcells' functions.

Can someone start me off with a more object oriented
approach to comparing values between two ranges having
exactly the same "shape" ?

Thanks. Neal Z

EndRow = 1847 'first range
OffSet = 1000 'copied range is 1000 rows below end of 1st range.
With Ws
For Row = 1 To EndRow '2847 1st row of copy
CheckRow = Row + EndRow + OffSet - 1
For Col = 5 To 100
'ignore cells with =row formulas as diff 'copy' row values do not
matter.
If InStr(.Cells(Row, Col).Formula, "=ROW") < 1 Then

If .Cells(Row, Col).Value < .Cells(CheckRow, Col).Value Then
TextA = .Cells(Row, Col).Value & " at row/col " _
& Row & "/" & Col & vbCr & .Cells(CheckRow, Col).Value _
& " at row " & CheckRow
Debug.Print TextA
Exit Sub
End If

End If
Next Col
Next Row
End With

--
Neal Z


All times are GMT +1. The time now is 06:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com