VBA Conditional Formatting

Declamatory

Active Member
Joined
Nov 6, 2014
Messages
319
Hi Folks,

Would someone be able to help me with some VBA code for conditional formatting?

I would like to highlight cells yellow in columns A, B, C and D if the corresponding cell in column D contains the word Redemption.

There could be any number of rows in the sheet called Paste Tab that the condition would need to apply to.

Thanks
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Sorry. I should have clarified. It is not a formula. Just text.

So if D56 contains the word Redemption then A56, B56 C56 and D56 would highlight yellow.

Thanks for the reply.
 
Upvote 0
You could put this in the code module for the sheet in question.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim oneCell As Range
   
    With Target
        If Not (Application.Intersect(.Cells, Range("D:D")) Is Nothing) Then
            For Each oneCell In Application.Intersect(.Cells, Range("D:D"))
                oneCell.EntireRow.Range("A1:D1").Interior.Color = IIf(0 < InStr(1, oneCell.Value, "Redemption", vbTextCompare), vbYellow, vbWhite)
            Next oneCell
        End If
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,597
Members
449,038
Latest member
Arbind kumar

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