English 中文(简体)
Conditional Formatting in Excel
原标题:

I m very new to Excel and VBA and was wondering if there is a way I could make conditional formatting based on values in a drop down list (created from data validation).

I currently have a warning if the user enters something that is not valid (data validation), but I want to change the cell s background color to red if invalid, or green if valid.

Again the options I want to test against are in the data validation created drop down list.

最佳回答

The easiest way to do this is to create the list in cells somewhere on your sheet. Then you use the named range ability to give it a name, let s say for this example ValidList. You give it the name by selecting the list, then go to the Insert menu and choose Name->Define, then enter the name and hit ok.

You then go to the cell in questions (we ll use A1 for this example), select it, then go to the data validation menu. When you choose the list option, enter the following for the Source:

=ValidList

Then having the cell selected you go to conditional formatting, choose the formula option, then enter the following formula, and your desired result:

=ISERROR(MATCH(A1, ValidList, 0)

Note, that the only time this will really help you is if someone does a Paste Special on a forbidden value, since otherwise data validation will catch the error (unless you re still allowing them to enter incorrect data).

问题回答

Go to the Format menu, select "Condition Formatting..."

You can set formulas there for any condition.





相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签