Hi
Firstly, I have to say that I am very new to VBA and have hardly used it before.
So I have 3 ranges on a worksheet, with the zeros lining up with each number above:
Range 1:
25 50 85 180 350 500 650 850
0 0 0 0 0 0 0 0
Range 2:
25 50 85 180 350 500 650 850
0 0 0 0 0 0 0 0
Range 3:
20 40 80 160 280 400 500 600
0 0 0 0 0 0 0 0
So I need to compare range 2 with range 1 and if and only if all the values in each cell are exactly the same should "OK" be printed in a certain cell in the worksheet
I also need to do exactly the same thing for range 3 and range 1. I do not want the user to have to select the range themselves, instead I want that to be defined in the macro itself, and the two comparisons can be made in separate macros.
Currently I have this code, but it prints OK all the time:
Sub Check_TEST2()
Dim CompareRange As Variant, x As Variant, y As Variant
Set CompareRange = Range("")
Set CompareRange2 = Range("")
For Each x In CompareRange2
For Each y In CompareRange
If x <> y Then Cells(16, 33) = "NOT OK"
If x = y Then Cells(16, 33) = "OK"
Next y
Next x
End Sub
Can anyone show me what macro would solve this?
Thanks for any help!
Firstly, I have to say that I am very new to VBA and have hardly used it before.
So I have 3 ranges on a worksheet, with the zeros lining up with each number above:
Range 1:
25 50 85 180 350 500 650 850
0 0 0 0 0 0 0 0
Range 2:
25 50 85 180 350 500 650 850
0 0 0 0 0 0 0 0
Range 3:
20 40 80 160 280 400 500 600
0 0 0 0 0 0 0 0
So I need to compare range 2 with range 1 and if and only if all the values in each cell are exactly the same should "OK" be printed in a certain cell in the worksheet
I also need to do exactly the same thing for range 3 and range 1. I do not want the user to have to select the range themselves, instead I want that to be defined in the macro itself, and the two comparisons can be made in separate macros.
Currently I have this code, but it prints OK all the time:
Sub Check_TEST2()
Dim CompareRange As Variant, x As Variant, y As Variant
Set CompareRange = Range("")
Set CompareRange2 = Range("")
For Each x In CompareRange2
For Each y In CompareRange
If x <> y Then Cells(16, 33) = "NOT OK"
If x = y Then Cells(16, 33) = "OK"
Next y
Next x
End Sub
Can anyone show me what macro would solve this?
Thanks for any help!