Conditional Formatting in table using the column names in the Formula

SA_Carpenter

New Member
Joined
Jul 1, 2022
Messages
1
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello,

Hopefully someone can help

I am trying to highlight the values in one "Amdt x" whenever it differs from the value in "Current Amdt". Originally I called out the column letter, but as the table changes and gets updated I want to use the column names to avoid having to rework the macro every time.

My table looks something like
1656694056038.png

and the code I was using before is

VBA Code:
ActiveSheet.ListObjects("Table1").ListColumns("Amdt x").Range.Select
        Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$D2<>$E2"
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
                    .PatternColorIndex = xlAutomatic
                    .Color = 6053086
                    .TintAndShade = 0

Essentially I wanna replace $D2 with Amdt x and $E2 with Current Amdt. Hopefully I explained this well enough and any help would be appreciated
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Conditional formatting formulas cannot include structured table references.
 
Upvote 0

Forum statistics

Threads
1,215,426
Messages
6,124,828
Members
449,190
Latest member
rscraig11

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