Thread: [Solved] show a cell
View Single Post
 
Old 05-25-2012, 05:48 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,365
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub GetColRef()
Dim i As Long, j As Long, k As Long, Rng As Range
With ThisWorkbook.Worksheets("Data")
  j = .Range("A" & .Rows.Count).End(xlUp).Row
  For i = 2 To j
    Set Rng = ThisWorkbook.Worksheets("Report").Cells.Find(what:=Right(.Cells(i, 2).Value, 8), LookIn:=xlValues, _
      LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True)
    If Rng Is Nothing Then
      .Cells(i, 5).Value = ""
    Else
      For k = 1 To i
        If Rng.Offset(k, 0).Interior.ColorIndex = 6 Then
          .Cells(i, 5).Value = Rng.Offset(k, 0).Value
          Exit For
        ElseIf Rng.Offset(-k, 0).Interior.ColorIndex = 6 Then
          .Cells(i, 5).Value = Rng.Offset(-k, 0).Value
          Exit For
        End If
      Next
    End If
  Next
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote