Hi koala,
In a Standard Module:
Option Explicit
Sub UpdateData()
Dim DataRange As Range, TempRange As Range
Dim FirstAddress As String
With ThisWorkbook.Worksheets("Data") '//Or use the sheet's codename//
Set TempRange = RangeFound(.Range(.Cells(3, "I"), .Cells(.Rows.Count, "AV")))
'// Bail if empty sheet//
If TempRange Is Nothing Then Exit Sub
'// set a reference to the range on Data sheet //
Set DataRange = .Range(.Cells(3, "I"), TempRange)
End With
Set TempRange = Nothing
'// find an initial cell with XYZ... //
Set TempRange = RangeFound(DataRange, "XYZ", , , xlWhole, , , True)
With DataRange
If Not TempRange Is Nothing Then
'// ...then loop until we run into the same cell again... //
FirstAddress = TempRange.Address
Do
'// checking against the other sheet for the same address //
If ThisWorkbook.Worksheets("Output").Cells(TempRange.Row, TempRange.Column).Value = "m" Then
ThisWorkbook.Worksheets("Output").Cells(TempRange.Row, TempRange.Column).Value = "Y"
'// just to show results //
ThisWorkbook.Worksheets("Output").Cells(TempRange.Row, TempRange.Column).Interior.ColorIndex = 3
End If
Set TempRange = .FindNext(TempRange)
Loop While Not TempRange.Address = FirstAddress
End If
End With
End Sub
Function RangeFound(SearchRange As Range, _
Optional FindWhat As String = "*", _
Optional StartingAfter As Range, _
Optional LookAtTextOrFormula As XlFindLookIn = xlValues, _
Optional LookAtWholeOrPart As XlLookAt = xlPart, _
Optional SearchRowCol As XlSearchOrder = xlByRows, _
Optional SearchUpDn As XlSearchDirection = xlPrevious, _
Optional bMatchCase As Boolean = False) As Range
If StartingAfter Is Nothing Then
Set StartingAfter = SearchRange(1)
End If
Set RangeFound = SearchRange.Find(What:=FindWhat, _
After:=StartingAfter, _
LookIn:=LookAtTextOrFormula, _
LookAt:=LookAtWholeOrPart, _
SearchOrder:=SearchRowCol, _
SearchDirection:=SearchUpDn, _
MatchCase:=bMatchCase)
End Function
Hope that helps :-)
Mark