-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CustomConditionalFormat applied to a RangeAreas behaves differently depending on the Range used to fetch the ConditionalFormat #5194
Comments
Hi @sndurkin, thx for reaching out here. |
Hi @RuizhiSunMS, thanks for the response. I don't think that will work because that's fundamentally a different formula. My original formula says: |
@sndurkin, I think I got your point. Mark it as #9626786 into our backlog. I will involve experts to discuss this behavior. Will reply here if any update. |
Hi @sndurkin , Would you please try the following script? I changed to formulaR1C1: "=RC = 1" ,which means each cell in that range will check if its own value is 1.
|
Hi @qinliuMSFT, that does seem to work. AFAIK the I would still argue that this bug should stay open; IMO the |
Hi @sndurkin, Happy New Year! The behavior you're observing is by design due to how Excel handles relative references in conditional formatting rules. Also, the logic for getting formulas and putting formulas is slightly different. When you get the formula from a conditional format, it retrieves the formula relative to the top-left cell of the range. However, when you set the formula, it applies the formula relative to the current range. So, to maintain the same conditional formatting rule, the recommended approach is:
This approach and the formulaR1C1 I mentioned last time are both the approaches we advocate, please let us know if you have any other questions. |
Hi @qinliuMSFT, thanks for the detailed response, the behavior is understandable. I've implemented the |
Provide required information needed to triage your issue
Your Environment
Expected behavior
When updating the formula for a
CustomConditionalFormat
applied to aRangeAreas
, I expected the formula to be applied as-is, without adjustment. In the example ScriptLab script, the formula I provide is=C1 = 1
. I expected it to remain that after applying it.Current behavior
The formula is adjusted to
=A1 = 1
after applying it. I believe this happens because theCustomConditionalFormat
is applied to aRangeAreas
that is composed of bothC1
andE1
, but theCustomConditionalFormat
instance is fetched from cellE1
(the 2ndRange
from theRangeAreas
) rather than from cellC1
.Steps to reproduce
CustomConditionalFormat
for cellsC1
&E1
, highlighting cells in green if they equal1
using formula=C1 = 1
.CustomConditionalFormat
from cellE1
and set the exact same formula,=C1 = 1
again.Link to live example(s)
https://gist.github.com/sndurkin/a45541e3f07d791996e4efa33cabe1a0
Provide additional details
N/A
Context
I would expect the
CustomConditionalFormat
to behave the same regardless of whichRange
within theRangeAreas
it was fetched from, presumably because it's the exact same conditional format. I don't really have a workaround for this, because even if I derived the firstRange
associated with theRangeAreas
for theCustomConditionalFormat
, I wouldn't necessarily know whichCustomConditionalFormat
from the firstRange
is the same as the one I originally fetched, because there is no globally uniqueid
I can use to compare them.Useful logs
The text was updated successfully, but these errors were encountered: