I have an Excel spreadsheet (don't ask), with a 4x6 table with headers Day 1 , Day 2 , Day 3 , and Total . However, a formula is changing the location of the Total according to the date, so at any point Day 3 could be removed and instead replaced with Total if the date detects that we are only up to Day 2 , so we needn't display headers for Day 3 yet.
I wanted to use conditional formatting to style everything under Total a certain way, so I wrote this formula for the option Use a formula to determine which cells to format :
=IF(INDIRECT(CONCATENATE(CHAR(COLUMN()+64), 1)) = "Total", TRUE, FALSE)
This should be formatting any cell where the cell in its column's first row is equal to "Total". However, it simply never styles anything!
To troubleshoot, I attempted selecting just one column (ie C ) and applying a modified form of the rule just to that:
=IF(INDIRECT(CONCATENATE("C", 1)) = "Total", TRUE, FALSE)
... It worked! Then, I tried simply putting the first formula into a cell, and it was displaying TRUE and FALSE correctly. Everything seems to work, but for some reason that I could not figure out the conditional formatting would never apply.
Can someone please explain why?
PS in the question I wrote a simplified example, in the real thing I have 31 days instead of three, so it would be a major hassle to go through each column individually
INDIRECT(CONCATENATE(CHAR(COLUMN()+64), 1))
is probably the worst possible way I can think of to reference the cell in the first row and same column.
Instead of this:
INDIRECT(CONCATENATE(CHAR(COLUMN()+64), 1)) = "Total"
Try this (for example, for a conditional formatting rule in the A
column, and apply the rule where ever else you need it):
A$1 = "Total"
These two formulas have the same effect.
OK... I solved this myself. Turns out that my formula was fully correct, but for some strange reason it didn't like the IF statement; I replaced it with:
INDIRECT(CONCATENATE(CHAR(COLUMN()+64), 1)) = "Total"
and it works fine!
However, I would still appreciate it if someone could explain why this happened (for future reference)
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.