Comparison within borders

aa2000

Board Regular
Joined
Aug 3, 2011
Messages
87
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.

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
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
my 2 cents: forget this idea, it sounds to me like a very bad idea to base your calculation ranges on a formatting property. It can be done, but it would be unreasonably complex, and also I am afraid it would be unreliable (at best).

Can you show an example of what the data looks like? I'm sure there will be easier and better ways to do what you want without having to rely on border formatting...
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,421
Members
452,913
Latest member
JWD210

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top