We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ConditionalFormats to affect another cell

Thread ID:

Created:

Updated:

Platform:

Replies:

43830 May 4,2006 07:52 PM UTC May 23,2006 04:19 PM UTC WinForms 3
loading
Tags: XlsIO
Elsa
Asked On May 4, 2006 07:52 PM UTC

Hi! Can a conditional format affect a different cell that may or may not be in the same worksheet as the cell with the conditional format? If so, how is this accomplished? Thanks! Elsa

Elsa
Replied On May 5, 2006 03:24 PM UTC

Now I understand conditional formatting a bit better. The cell that has the conditional formatting will be affected by the logical value of one or more cells. I am trying to use your ConditionalFormats property and refer to named ranges like this: //Applying conditional formatting to "A7" for format type as CellValue( LessOrEqual) sheet.Range["A7"].Text = "Show"; IConditionalFormats condition6 = sheet.Range[ "A7" ].ConditionalFormats; //Adding formats to IConditionalFormats collection IConditionalFormat condition7 = condition6.AddCondition(); condition7.FormatType = ExcelCFType.Formula; condition7.FirstFormula = "=OR([Value1] = 0, [Value2] > 0, [Value3] = 13)"; sheet.Range["A7"].Text = "Either Value1 = 0 or Value2 > 0 or Value3 = 13"; //Setting format properties. condition7.Color = ExcelKnownColors.White; I am getting an error "Can''t parse formula." It doesn''t seem to understand "Value1" or "[Value1]." How can I fix this? Thanks, Elsa >Hi! > >Can a conditional format affect a different cell that may or may not be in the same worksheet as the cell with the conditional format? If so, how is this accomplished? > >Thanks! > >Elsa

Administrator [Syncfusion]
Replied On May 5, 2006 08:46 PM UTC

Hi Elsa, I was able to see some limitations in our conditional format formula support but I was able to work around these issues, here is the modified sample code that works workbook.ThrowOnUnknownNames = false; lname = workbook.Names.Add("Value1"); lname.RefersToRange = sheet.Range["A1"]; lname = workbook.Names.Add("Value2"); lname.RefersToRange = sheet.Range["A3"]; lname = workbook.Names.Add("Value3"); lname.RefersToRange = sheet.Range["A5"]; IConditionalFormats formats = sheet.Range["A7"].ConditionalFormats; //Adding formats to IConditionalFormats collection IConditionalFormat condition7 = formats.AddCondition(); condition7.FormatType = ExcelCFType.Formula; condition7.FirstFormula = "=OR(Value1=0,Value2>0,Value3=13)"; //Setting format properties. condition7.BackColor = ExcelKnownColors.Red; sheet.Range["A7"].Text = "Either Value1 = 0 or Value2 > 0 or Value3 = 13"; Notes on the modified code 1) Please add the names to the workbook and not to the worksheet. 2) There should be no empty space in a formula Please let me know if you have any questions. Thanks, Stephen.

Elsa
Replied On May 23, 2006 04:19 PM UTC

This did it. Thank you!

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;