View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Conditional Formating - Change Color

For Each rcellIm In rngIm.Cells
For Each rcellDt In rngDt.Cells
If InStr(1, rcellDt.Value, rcellIm, vbTextCompare) Then
if isempty(rcellDt.Offset(0, 5)) then
rcellDt.Offset(0, 5) = rcellIm.Offset(0, 3)
else
rcellDt.Offset(0, 5).Interior.ColorIndex = 3
End If
End If
Next rcellDt
Next rcellIm

--
Regards,
Tom Ogilvy


"hfazal" wrote in message
...
Hi, I have the function below, which is a loop and then performs and if
function, however I need another if statement inside the if statement

below
that will only do the rcellDt.Offset(0, 5) if it is empty otherwise it

should
change the color to red.

For Each rcellIm In rngIm.Cells
For Each rcellDt In rngDt.Cells
If InStr(1, rcellDt.Value, rcellIm, vbTextCompare) Then
rcellDt.Offset(0, 5) = rcellIm.Offset(0, 3)
End If
End If
Next rcellDt
Next rcellIm

Hope someone can help.

Thanks,

HFazal