excel training in uk - if statements
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel Training and help » excel training in uk - IF Statements

excel training in uk - IF Statements

resolvedResolved · Low Priority · Version Standard

replyReply Fri 23 Nov 2007, 09:50Trainer Sandy said...

IF Statements

When writing an IF statement, how can I make the true statement result appear in red text and the false statement appear in blue text.


Thank You
Sandy

For upcoming training course dates see: Pricing & availability

replyReply Fri 23 Nov 2007, 10:24Trainer Sandy said...

RE: IF Statements

The answer to this is to use the Conditional Formatting feature in the Format menu of Excel.

Once you have written your IF statement e.g.

=IF(C2>200,"Pass","Failed")

and have used the Autofill handle to copy the result of your formula down the worksheet, e.g. C2:C20

Keep these cells e.g. C2:C20 selected and select Format menu, Conditional Formatting...

Choose, Formula Is from the drop down, just under Condition 1
Now re-write your IF statement e.g.

=IF(C2>200,

When writing the True and False statement into the Conditional Formatting box you MUST not type in the original True and False statements as this will not work, instead substitute Pass with True and Fail with False.

So your statement will now read as:

=IF(C2>200,True,False)

Click the format button in the dialog box, click the font tab to choose a font colour e.g. red

Click OK

Your True statement e.g. Pass will now appear in Red text.

To display your False statement e.g. Fail in another font colour e.g. blue

Keep your range highlighted e.g. C2:C20

Select Format menu, Conditional Formatting...

Click Add to add a second condition

Choose, Formula Is from the drop down, just under Condition 2
Now re-write your IF statement e.g. - this time noting that False comes before True.

=IF(C2>200,False,True)

Click the format button in the dialog box, click the font tab to choose a font colour e.g. blue

Click OK

Your False statement e.g. Fail will now appear in Blue text.


Hope this helps
If you want to find out more about IF Statements, please check the syllabus for our Excel Advanced course.

Sandy

 

Excel tip:

Calculate age or service

The DATEDIF() function in Excel calculates the number of days, months, or years between two dates. So, this function makes it easy to calculate a person's age. To try this tip:

In a blank worksheet, type the birth date in cell A1, using slashes to separate day, month, and year.
In cell A2, type =DATEDIF(A1,TODAY(),"y") and press ENTER.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard