Inserting an xlookup in VBA code to format a cell based on it's info in another table / sheet.

crzytimes

New Member
Joined
Oct 28, 2016
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Hi - I'm trying to reduce the number of "helper" columns I have in a table as it's gotten too big. My helper column is just using an xlookup to pull the data into the helper column. I use the helper column to conditionally format a row or cells. I'm doing something wrong, and can't quite figure it out.

Below is the original VBA Code, what I want to do is replace "=PlanSched!$O2=""TECO""" with a formula that says "=xlookup($G2,COOISPI[Order],COOISPI[Status])=""TECO""". Where COOISPI is a table in another worksheet labeled "SAP_Export".

Original VBA Code

VBA Code:
' Date Color Code
    Sheets("PlanSched").Range("$C2", Range("$C2").End(xlDown)).Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
    "=PlanSched!$O2=""TECO"""
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Bold = True
        .Italic = False
        .Strikethrough = False
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = -0.14996795556505
    End With
    Selection.FormatConditions(1).StopIfTrue = False
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,214,626
Messages
6,120,602
Members
448,974
Latest member
ChristineC

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