ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional Formating - Change Color (https://www.excelbanter.com/excel-programming/353404-conditional-formating-change-color.html)

hfazal

Conditional Formating - Change Color
 
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

Tom Ogilvy

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





All times are GMT +1. The time now is 05:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com