Say I have set a value of 55 on cell B2.
If it's value is 55, the cell's background color should be green. So I created a new rule using a formula by selecting "User a formula to determine which cells to format" and set the formula to the following:
=B2 = 55
It worked, obviously. But because we don't want to hard-code the row because we are using this spreadsheet as a template in an application that generates more rows by simply copying that cell to another row, I set the formula to this one:
=INDIRECT( "B" & row() ) = 55
And because we actually want two conditions and our requirement is not as simple as that, I tried the following:
=AND( INDIRECT( "B" & row() ) >= 50, INDIRECT( "B" & row() ) <= 60 )
Which means set the background to green if the value is between 50 and 60 (inclusive). And that did not work. But the following works:
=AND( INDIRECT( "B" & "2" ) >= 50, INDIRECT( "B" & "2" ) <= 60 )
Could anyone tell me why does the latter work but the former that calls row() doesn't?
It seems row() only doesn't work if it's used with combination of AND() and INDIRECT() as demonstrated below:
=AND( ROW() = 2 ) -> this one works
=INDIRECT( "B" & row() ) = 55 -> this one works too
=AND( INDIRECT( "B" & row() ) ) = 55 -> doesn't work :((
Could someone explain this why? Is this a bug in Excel 2010? And how do I solve this problem?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…