View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
gaba gaba is offline
external usenet poster
 
Posts: 83
Default Find value in another column, change Interior.colorIndex

First post didn't work. I apologize if this is a duplicate.

Hello there,
I wrote the following code to find a value in column B if the cell in
columnS has an Interior.color.Index = 44, transfer the color to the cell with
same value in B.
(calcLastRow declared already)

Dim ColumnB As Range, SrcChk1 As Range
Dim DestChk1 As String
Dim DestChk2 As String

Set ColumnB = Range("B14", "B" & calcLastRow)
Range("N14").Select

With ColumnB
Do
DestChk1 = (ActiveCell.Offset(0, 5).Interior.ColorIndex = 44)
DestChk2 = Trim(ActiveCell.Offset(0, 0).Value)
Set SrcChk1 = .Find(What:=Trim(DestChk2), LookAt:=xlWhole,
SearchOrder:=xlByColumns)


On Error Resume Next
For Each c In ColumnB
If Not SrcChk1 Is Nothing Then
If c.Offset(0, 0).Value = Trim(DestChk2) Then
c.Offset(0, 2).Interior.ColorIndex = 44
c.Offset(1, 2).Interior.ColorIndex = 44

End If
Err.Clear

End If 'nothing
Next

ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, 0))

End With

I can't find where I'm making the mistake... is going thru column N Offset
0, 5 (Column S has some null values) but is not finding the value on Column B.

Any help will be greatly appreciated!
Thanks
Gaba