View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz[_2_] JLGWhiz[_2_] is offline
external usenet poster
 
Posts: 1,565
Default Match Ranges problem ,

Disregard the previous code and use this one;

Sub QQQ()
Dim lr As Long, i As Long, j As Long, c As Range
Dim sh As Worksheet, rng As Variant
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
rng = Array("A1:C1", "A2:C2", "A3:C3")
For i = 0 To 2
For j = 6 To 12
For Each c In Range(rng(i))
If c = sh.Cells(c.Row, j) Then
sh.Cells(c.Row, j) = "QQQ"
End If
Next
Next
Next
End Sub

The other one was comparing the wrong cells.


"ytayta555" wrote in message
...
On 2 mar., 22:37, "Rick Rothstein"
wrote:
Of course, I'm assuming you want to assign "QQQ" to the cells located at
the
same offset distance (the myOffset variable) from range2's cells as you
did
for range1's cells.


It was my mistake in description , and I
apologise . The second range , myRange 2 is bigger
in columns then myRange1

For eg :
Set range1 = Range("A1:C3")
Set range2 = Range("F1:K3")

Every cell in myRange2 I need to compare with every cell
in myRange1 , but NOT first cell from myRange2 with ALL cells from
myRange1 , then second ... I mean , ALL cells from range2
compare with all cells from range 1 , BUT , ,,ROW BY ROW,, ,
with other words , in the same row .

The cells are not located at the same offset distance , because
range 2 is bigger in columns then range 1 .

It's a little bit complicate . Please to assist me .....