Conditional formatting

jpen

Active Member
Joined
Jun 19, 2002
Messages
398
Hi all,

The conditional formatting on a worksheet is working correctly. =$XFD3="Reject".

Now I want to put this condition formatting in VBA

With Range("H2:S" & LaatsteRij).FormatConditions.Add(Formula1:="=$XFD2=Reject").Interior.Color = 3
End With

But this is not working. By changing it in Formula1:="=$XFD2="Reject"" it gives already in VBA and error (red line/font).


Any ideas how to solve this?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

MrJoosten

Board Regular
Joined
Nov 12, 2016
Messages
118
hi, don't know if it works but:

Code:
Sub format()
 
    Dim lr As Long
    
    lr = Cells(Rows.Count, 1).End(xlUp).Row 'counts rows used in column A 
    
    Range("A1:A" & lr).Select 'select range A1 to last used cel in column A 
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=""d"""  'put here your specific word
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    
    With Selection.FormatConditions(1).Interior 
        .PatternColorIndex = xlAutomatic
        .Color = 255 'color is red
        .TintAndShade = 0
    End With
   
End Sub
 
Upvote 0

Forum statistics

Threads
1,190,783
Messages
5,982,900
Members
439,806
Latest member
ShakeShark1

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
Top