# Conditional VBA?

#### KennyA

##### Board Regular
Hello all!
I am not sure how to label what I am attempting to accomplish but here it goes.
Excel 2013, Windows 7
All on Sheets ("Sheet1")

Cell ID's
In cell B8 I have a manual entry for the number of days to actually perform the task.
In cell B9 I have a manual entry for number of days before B8 Value as the warning trigger.
In cell B11 I have a simple formula to calculate the remaining days before the task is due.
In Cell F33 I have the percent of components on hand.

What I am trying to accomplish:
I want cell B12 to turn RED and have text that says "DANGER" in white letters in cell B12 if:
B8+B9 is > B11 And F33 is <100%
This will signal the warning that the drop dead date is nearly not achievable.

so let's say this for further explanation:
B8 = 5 days and B9 = 5 days. That is 10 days
B11 = 13 days and F33 is < 100%
No warning.
But if B11 hits 9 days and F33 is still < 100% I get warned.

### Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Does it have to be done using VBA? It is rather straightforward using a formula and Conditional Formatting.

If you want to go this route, start by entering the formula =IF(AND(SUM(B8:B9) > B11,F33 < 1),"DANGER","") in B12.

Now select B12, Conditional Formatting, New Rule, Use a formula, =AND(SUM(B8:B9) > B11,F33 < 1), Red Fill, White Font, OK.

Last edited:
I did what you said to do.
I get an error "There is a problem with this formula" when entering the formula in the conditional formatting step
Now select B12, Conditional Formatting, New Rule, Use a formula, =AND(SUM(B8:B9) > B11,F33 < 1), Red Fill, White Font,

I did what you said to do.
I get an error "There is a problem with this formula" when entering the formula in the conditional formatting step
Now select B12, Conditional Formatting, New Rule, Use a formula, =AND(SUM(B8:B9) > B11,F33 < 1), Red Fill, White Font,

That's odd... I just cleared everything and followed the steps exactly and it seems to work fine on my end.

You can try changing the CF formula to =B12="DANGER" and that should work too. That is as long as you have the IF formula in B12 already.

That did not work either. I did also try copying and pasting the CF formula just as you wrote it and it does not work.

What about trying it in VBA?

That did not work either. I did also try copying and pasting the CF formula just as you wrote it and it does not work.

What about trying it in VBA?

Start by creating a sample worksheet from the following data (I moved F33 up to F9 for display purposes). See if you can get it working on that and then you can see why it is not working on your actual data.

Excel 2010
ABCDEF
9# Days before B85% of components on hand99%
10
11Remaining Days9
12DANGER
Sheet2
Cell Formulas
RangeFormula
B12=IF(AND(SUM(B8:B9) > B11,F9 < 1),"DANGER","")

This is what I see.

Apparently the image did not go through.
I get the error in the CF formula step.

Apparently the image did not go through.
I get the error in the CF formula step.

Did you copy and paste my example from post #6 and then try it on that? If so, are you able to get the word "DANGER" into cell B12?

Last edited:
Yes and DANGER did show in cell B12

Replies
1
Views
140
Replies
3
Views
515
Replies
4
Views
150
Replies
7
Views
248
Replies
3
Views
91

1,203,323
Messages
6,054,727
Members
444,747
Latest member
Jaborsum

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back