VBA Conditional format

Alisya

Well-known Member
Joined
Nov 27, 2008
Messages
532
Hi i am after a VBA code that will look in Col D in sheet Test, if string "NEW" found and the data in col E is blank then format "NEW" cell RED

So e.g if D6 = "NEW" and E6 is blank then format D6 red
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
this assumes you have a header in the first row
Code:
Sub cond_form()
    lastrow = Cells(Rows.Count, 4).End(xlUp).Row
    For i = 2 To lastrow
        If UCase(Cells(i, 4)) = "NEW" And Cells(i, 5) = "" Then Cells(i, 4).Interior.Color = vbRed
    Next
End Sub


why don't you use the conditional formatting wizzzzzzzzard?
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,734
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top