简体   繁体   中英

Excel formula not working as conditional formatting formula

The formula =(MONTH(INDEX(Schedule, MATCH(D1, Schedule[[Full Name]:[Full Name]], 0), 7)) = MONTH( DATEVALUE( D$2 & "1" ) )) * (YEAR(INDEX(Schedule, MATCH(D1, Schedule[[Full Name]:[Full Name]], 0), 7)) = $B$3) * (INDEX(Schedule, MATCH(D1, Schedule[[Full Name]:[Full Name]], 0), 7)<> "") works fine in a cell but when I try to use it for conditional formatting I get the error "There is a problem with this formula".

My goal is to format the cells if all of the following three statements are true:

  • MONTH(INDEX(Schedule, MATCH(D1, Schedule[[Full Name]:[Full Name]], 0), 7)) = MONTH(DATEVALUE(D$2&"1"))
  • YEAR(INDEX(Schedule, MATCH(D1, Schedule[[Full Name]:[Full Name]], 0), 7)) = $B$3
  • INDEX(Schedule, MATCH(D1, Schedule[[Full Name]:[Full Name]], 0), 7) <> ""

I have tried using AND() and I've tried normal references instead of named ranges. Is there a reason why it would work in a cell but not in the conditional formatting menu? Thanks!

PS I am on the office insider beta channel

EDIT: Solved by @ScottCraner. I used INDIRECT() on all the named references and it worked. This is the final product: =(MONTH(INDEX(INDIRECT("Schedule"), MATCH(D1, INDIRECT("Schedule[[Full Name]:[Full Name]]"), 0), 7)) = MONTH( DATEVALUE( D$2 & "1" ) )) * (YEAR(INDEX(INDIRECT("Schedule"), MATCH(D1, INDIRECT("Schedule[[Full Name]:[Full Name]]"), 0), 7)) = $B$3) * (INDEX(INDIRECT("Schedule"), MATCH(D1, INDIRECT("Schedule[[Full Name]:[Full Name]]"), 0), 7)<> "")

This was solved by @ScottCraner. To use a named reference in conditional formatting, you have to use INDIRECT()

This is the final product: =(MONTH(INDEX(INDIRECT("Schedule"), MATCH(D1, INDIRECT("Schedule[[Full Name]:[Full Name]]"), 0), 7)) = MONTH( DATEVALUE( D$2 & "1" ) )) * (YEAR(INDEX(INDIRECT("Schedule"), MATCH(D1, INDIRECT("Schedule[[Full Name]:[Full Name]]"), 0), 7)) = $B$3) * (INDEX(INDIRECT("Schedule"), MATCH(D1, INDIRECT("Schedule[[Full Name]:[Full Name]]"), 0), 7)<> "")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM