Search : in
By :

Conditional Formatting

Last answer on Sep 26, 2008 11:00:59 am BST Badgermd163, on Sep 26, 2008 9:20:11 am BST 
 Report this message to moderators

I need to specify different text colours for certain conditions. This I can do with the conditional formatting but only for three conditions, I have tried to write some VBA code to allow me to call two or more routines to get more conditions The code only partially works, can anyone tell me where i am going wong, I am sure that this can be done. Code below. Thanks Badger163.

Sub Audit1()

Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""no"""
Selection.FormatConditions(1).Interior.ColorIndex = 3

Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""?"""
Selection.FormatConditions(2).Interior.ColorIndex = 3
Audit 2
End Sub

Sub Audit2()

Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""/"""
Selection.FormatConditions(1).Interior.ColorIndex = 8

Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""yes"""
Selection.FormatConditions(2).Interior.ColorIndex = 8

Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""n/a"""
Selection.FormatConditions(3).Interior.ColorIndex = 8

End Sub
,

Configuration: Windows XP
Internet Explorer 6.0

Best answers for « Conditional Formatting » in :
Unlimited Conditional Formatting Show Unlimited Conditional Formatting Introduction Principle Code Introduction The limitation of MFC (Conditional Formatting) to Excel version 2007 is less than 3. This is very short. Having seen many applications to push the limit, I am...
Colouring cells on conditions ShowColouring cells on conditions There are many pratical functions under Excel which is not commonly used. Example: If you wish a cell automatically turns red (or other formatting border, frame etc) under one condition: a result, a...
Avoid duplicates in Excel ShowAvoid duplicates in Excel In order to avoid duplication when encoding in a column from an excel sheet: take the conditional format on the first cell under the headings (eg A2) choose the following formula:...
[VBA] A function that returns the color of an active MFC Show[VBA] A function that returns the color of an active MFC This function returns the value of the active format in conditional formatting. With the function below, two values can be returned. Mode = 0: the value of Interior.ColorIndex...
Download HP USB Disk Storage Format Tool ShowHP USB Disk Storage Format Tool is a small utility allowing to format a key USB or READER MP4. It also allows to make a key (Bootable). This software works with all keys and readers MP4 of the market. To make work this utility under Windows...
Download Format Factory ShowFormat Factory is an application that allows conversion of various types of media files. It has various characteristics that allow you to customize a lot of stuff like: Convert video formats, audio and picture shows. Repair damaged files. Reduce...
Spreadsheets - Conditional expressions ShowWhat is a Conditional Structure? Conditional structures are instructions that allow to test if a condition is true or not. Conditional structures may be associated together. To successfully execute these tests using logical functions, spreadsheets...
General Terms and Conditions of Use ShowAll Rights Reserved - 2009 - Communitic International Object These General Terms and Conditions are meant to define the ways in which the services of the website en.kioskea.net, hereafter "The Service," are made available, as well as the...
Spreadsheet - Functions ShowThe Concept of a Function Spreadsheets generally have a large number of integrated functions for processing data. There are hundreds, categorised as follows: Arithmetic functions that offer basic tools to process numerical data Statistical...

1

 Ivan-hoe, on Sep 26, 2008 11:00:59 am BST
  • +1

Hello Badger,
Actually you need only 2 conditions, since you use only two different formattings : green or red.
No VBA needed, use a formula in your conditionnal formatting instead.
Condition 1: =OR(A1="no";A1="?") ---> red colour
Condition 2: =OR(A1="/";A1="yes";A1="#N/A") --> green colour
Ivan.

Reply to Ivan-hoe