Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional formatting

Status
Not open for further replies.

thrilliam

Technical User
Oct 11, 2006
12
US
I do not know a thing about VBA but i need to expand my conditional formatting options to more than three options

I simply need to change the color of the text in a record in a form based upon a values in another field
ex.
if [Value]>100 make [Customer_Name] Font Red
if [Value]<100 and [Value]>75 make [Customer_Name] Font Orange
if [Value]<75 and [Value]>50 make [Customer_Name] Font Yellow
if [Value]<50 and [Value]>25 make [Customer_Name] Font Green

then if [Value]>100 and [Payment_Received] = "no" make [Customer_Name] Font Red and background blue

etc.

Any help would be greatly appreciated
Thanks,
Will
 
Hello:

In your code...

[Customer_Name].ForColor=VbRed
[Customer_Name].ForColor=VbOrange
[Customer_Name].ForColor=VbYellow
[Customer_Name].ForColor=VbGreen
Regards
Mark
 
Hmm there has to be more to it than that. I appreciate the help but i still cant get anything to work. I have tried by looking at examples of code but none of it works correctly.
 
[Customer_Name]. looks like a field.
You need to set the control's ForeColor property, i.e.

txtTextBox.ForeColor = vbRed
or
txtTextBox.ForeColor = RGB(255,0,0)

Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.
 
Hi,

you need the following setup:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

With Target
    Select Case .Value
        Case Is > 100
            .Font.ColorIndex = 3
        Case 75 To 100
            .Font.ColorIndex = 5
        Case "etc..."
    End Select
End With

End Sub

Cheers,

Roel
 
btw right click on the tab and then select View Code. That's where you need to put your VBA.

Cheers,

Roel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top