0

I'm trying to use conditional formatting to change the background color of a cell in excell based on if the cell in a different sheet is not null.

Is it possible to do this in a function?

My condition is this:

if(NOT(isBlank($Sheet1!I2), make green, make red)
1
  • 1
    I just wanted to show that there are more options available than only two states ;-) Commented Sep 9, 2014 at 12:10

2 Answers 2

1

Why can't you solve it with Conditional Formatting?

Just create a new rule:

Create new rule

And then enter the formula with your check (for instance =Sheet2!$D$6<>""):

Enter formula

Create one rule for green fornmatting and one for red formatting ;-)

Sign up to request clarification or add additional context in comments.

Comments

0

This is the code I use in VB.Net to add conditional formatting, feel free to adapt it to your needs. In this case it's validating that certain cell has a value greater than 0. Remember that if you have some doubt about excel coding you can always record a new macro with the desired behavior and see the generated code.

range = sheet.Range("A1")
validations = range.Validation
validations.Add(Type:=Excel.XlDVType.xlValidateDecimal, _
                AlertStyle:=Excel.XlDVAlertStyle.xlValidAlertStop, _
                Operator:=Excel.XlFormatConditionOperator.xlGreaterEqual, _
                Formula1:=0)
validations.InputTitle = String.Empty
validations.ErrorTitle = "Error: Select a decimal > 0"
validations.InputMessage = String.Empty
validations.ErrorMessage = "You must enter a decimal > 0" 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.