VBA to select sheet and conditional format to highlight differences

  • Objective: With reference to current sheet, select another sheet by user input and conditional format to highlight differences in cell f23 current sheet vs. f23 selected sheet

    I have combined a script from tom-urtis.5 with my recorded macro in order to achive this outcome.

    The conditional formating is applied, but for some reason the condional formating formula is ending up encapsulated with double quotes

    i.e "F23<>Sheet1!F23"

    When I remove the douple quotes the formating works.

    i.e F23<>Sheet1!F23

    What am I doing wrong in this code?

    Blessed are the pessimists for they shall have backups......

  • Hello,

    At first sight, seems you just forgot the equal sign ...

    Range("F23").FormatConditions.Add Type:=xlExpression, Formula1:="=F23<>" & optCaption & "!F23"

    Hope this will help


    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!