Hello guys
I am trying to right a macro that will compare different ranges with each other. Each range is enclosed by borders, so I would like the macro to compare what is within the borders to the next range.
Essentially I am comparing the same functions from three different projects to see if their values are the same. So for each project, there are a certain number of functions, consisting of x and y values, and each function in each project is separated by borders. They are arranged vertically so all the functions for project A are listed below one another. I want to compare function A of project A with function A of project B and function A of project C, and so on. (makes sense?)
I'd like the code to look for the borders and compare across, rather than have to tell it the ranges to compare since each project contains some 500 functions.
Currently the code I have turns each one into a text string and compares them, which works fine, but I'd like to adapt it to compare functions within borders on its own.
Where Rng1 is function a, project a and Rng2 is function a, project b.
Does anyone know a way to do this?
Let me know if you need more info/explanation
Thanks
I am trying to right a macro that will compare different ranges with each other. Each range is enclosed by borders, so I would like the macro to compare what is within the borders to the next range.
Essentially I am comparing the same functions from three different projects to see if their values are the same. So for each project, there are a certain number of functions, consisting of x and y values, and each function in each project is separated by borders. They are arranged vertically so all the functions for project A are listed below one another. I want to compare function A of project A with function A of project B and function A of project C, and so on. (makes sense?)
I'd like the code to look for the borders and compare across, rather than have to tell it the ranges to compare since each project contains some 500 functions.
Currently the code I have turns each one into a text string and compares them, which works fine, but I'd like to adapt it to compare functions within borders on its own.
Code:
Sub Function A()
Dim Rng1 As Range, Rng2 As Range
Dim Str1 As String, Str2 As String
Dim Match As String
Set Rng1 = Range("B4:I5")
Set Rng2 = Range("L4:S5")
For Each Cell In Rng1
Str1 = Str1 & Cell.Value
Next
For Each Cell In Rng2
Str2 = Str2 & Cell.Value
Next
If Str1 = Str2 Then
Cells(6, 21) = "OK"
Else
Cells(6, 21) = "NOT OK"
End If
End Sub
Where Rng1 is function a, project a and Rng2 is function a, project b.
Does anyone know a way to do this?
Let me know if you need more info/explanation
Thanks