PC Review


Reply
Thread Tools Rate Thread

Conditional Formatting More Than three

 
 
Bob
Guest
Posts: n/a
 
      25th Dec 2008
What is the code to change the font to bold and also the color In a range in
Column D for five or six different conditions? For example:

West change to RED
East Change to BLUE
North Change to Green
Central Change to Yellow

Thanks in advance.
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      25th Dec 2008

Merry Xmas from Texas
You could use a worksheet_change event in the sheet module with select case

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Bob" <(E-Mail Removed)> wrote in message
news:F188213B-B812-45C3-AB68-(E-Mail Removed)...
> What is the code to change the font to bold and also the color In a range
> in
> Column D for five or six different conditions? For example:
>
> West change to RED
> East Change to BLUE
> North Change to Green
> Central Change to Yellow
>
> Thanks in advance.


 
Reply With Quote
 
Bob
Guest
Posts: n/a
 
      25th Dec 2008
Can you give me the complete code that should be added?

"Don Guillett" wrote:

>
> Merry Xmas from Texas
> You could use a worksheet_change event in the sheet module with select case
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "Bob" <(E-Mail Removed)> wrote in message
> news:F188213B-B812-45C3-AB68-(E-Mail Removed)...
> > What is the code to change the font to bold and also the color In a range
> > in
> > Column D for five or six different conditions? For example:
> >
> > West change to RED
> > East Change to BLUE
> > North Change to Green
> > Central Change to Yellow
> >
> > Thanks in advance.

>
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      25th Dec 2008
In case you can't figure this out. Right click sheet tab>view
code>copy/paste this>change color numbers to suit

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case LCase(Target)
Case "west": mc = 4
Case "east": mc = 5
Case "north": mc = 6
Case "central": mc = 7
Case Else
End Select

With Target
.Interior.ColorIndex = mc
.Font.Bold = True
End With
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Don Guillett" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Merry Xmas from Texas
> You could use a worksheet_change event in the sheet module with select
> case
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "Bob" <(E-Mail Removed)> wrote in message
> news:F188213B-B812-45C3-AB68-(E-Mail Removed)...
>> What is the code to change the font to bold and also the color In a range
>> in
>> Column D for five or six different conditions? For example:
>>
>> West change to RED
>> East Change to BLUE
>> North Change to Green
>> Central Change to Yellow
>>
>> Thanks in advance.

>


 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      25th Dec 2008
Private Sub Worksheet_Change(ByVal Target As Range)
Dim R As Range
Dim iColor As Long
Set R = Range("D1100") 'adjust to suit
If Intersect(Target, R) Is Nothing Or _
Target.Count > 1 Then Exit Sub
Vals = Array("WEST", "EAST", "NORTH", "SOUTH")
Nums = Array(3, 5, 10, 6)
For i = LBound(Vals) To UBound(Vals)
With Target
If UCase(.Value) = Vals(i) Then iColor = Nums(i)
If UCase(.Value) = Vals(i) Then .Font.Bold = True
End With
Next
With Target
.Interior.ColorIndex = iColor
End With
End Sub

Pasted into the sheet module.


Gord Dibben MS Excel MVP

On Thu, 25 Dec 2008 08:29:00 -0800, Bob <(E-Mail Removed)>
wrote:

>What is the code to change the font to bold and also the color In a range in
>Column D for five or six different conditions? For example:
>
>West change to RED
>East Change to BLUE
>North Change to Green
>Central Change to Yellow
>
>Thanks in advance.


 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      25th Dec 2008
Just a caveat with Don's code.

Cell font will turn Bold even if cell does not meet case select criteria.

Don't know if that matters or not.


Gord

On Thu, 25 Dec 2008 11:10:04 -0600, "Don Guillett"
<(E-Mail Removed)> wrote:

>In case you can't figure this out. Right click sheet tab>view
>code>copy/paste this>change color numbers to suit
>
>Private Sub Worksheet_Change(ByVal Target As Range)
>Select Case LCase(Target)
> Case "west": mc = 4
> Case "east": mc = 5
> Case "north": mc = 6
> Case "central": mc = 7
> Case Else
>End Select
>
>With Target
> .Interior.ColorIndex = mc
> .Font.Bold = True
>End With
>End Sub


 
Reply With Quote
 
Bob
Guest
Posts: n/a
 
      25th Dec 2008
The code works great if I retype the name in the cell. The sheet is already
filled out, is there a way to auto update with out retyping every name in the
column over?

"mikeaj72" wrote:

>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
> With Target
> Select Case .Value
> Case Is = "West"
> .Font.Bold = True
> .Interior.ColorIndex = 3
> Case Is = "East"
> .Font.Bold = True
> .Interior.ColorIndex = 5
> Case Is = "North"
> .Font.Bold = True
> .Interior.ColorIndex = 4
> Case Is = "Central"
> .Font.Bold = True
> .Interior.ColorIndex = 6
> Case Else
> .Font.Bold = False
> .Interior.ColorIndex = 0
> End Select
> End With
> End If
> End Sub
>
>
> --
> mikeaj72
> ------------------------------------------------------------------------
> mikeaj72's Profile: http://www.thecodecage.com/forumz/member.php?userid=46
> View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=44176
>
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      25th Dec 2008
Good point

With Target
.Interior.ColorIndex = mc
if target.interior.colorindex>0 then .Font.Bold = True
End With


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Gord Dibben" <gorddibbATshawDOTca> wrote in message
news:(E-Mail Removed)...
> Just a caveat with Don's code.
>
> Cell font will turn Bold even if cell does not meet case select criteria.
>
> Don't know if that matters or not.
>
>
> Gord
>
> On Thu, 25 Dec 2008 11:10:04 -0600, "Don Guillett"
> <(E-Mail Removed)> wrote:
>
>>In case you can't figure this out. Right click sheet tab>view
>>code>copy/paste this>change color numbers to suit
>>
>>Private Sub Worksheet_Change(ByVal Target As Range)
>>Select Case LCase(Target)
>> Case "west": mc = 4
>> Case "east": mc = 5
>> Case "north": mc = 6
>> Case "central": mc = 7
>> Case Else
>>End Select
>>
>>With Target
>> .Interior.ColorIndex = mc
>> .Font.Bold = True
>>End With
>>End Sub

>


 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      25th Dec 2008
Option Compare Text
Sub colorit()
For Each cell In ActiveSheet.UsedRange
With cell
Select Case .Value
Case Is = "West"
..Font.Bold = True
..Interior.ColorIndex = 3
Case Is = "East"
..Font.Bold = True
..Interior.ColorIndex = 5
Case Is = "North"
..Font.Bold = True
..Interior.ColorIndex = 4
Case Is = "Central"
..Font.Bold = True
..Interior.ColorIndex = 6
Case Else
..Font.Bold = False
..Interior.ColorIndex = 0
End Select
End With
Next
End Sub


Gord

On Thu, 25 Dec 2008 09:40:01 -0800, Bob <(E-Mail Removed)>
wrote:

>The code works great if I retype the name in the cell. The sheet is already
>filled out, is there a way to auto update with out retyping every name in the
>column over?
>
>"mikeaj72" wrote:
>
>>
>> Private Sub Worksheet_Change(ByVal Target As Range)
>> If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
>> With Target
>> Select Case .Value
>> Case Is = "West"
>> .Font.Bold = True
>> .Interior.ColorIndex = 3
>> Case Is = "East"
>> .Font.Bold = True
>> .Interior.ColorIndex = 5
>> Case Is = "North"
>> .Font.Bold = True
>> .Interior.ColorIndex = 4
>> Case Is = "Central"
>> .Font.Bold = True
>> .Interior.ColorIndex = 6
>> Case Else
>> .Font.Bold = False
>> .Interior.ColorIndex = 0
>> End Select
>> End With
>> End If
>> End Sub
>>
>>
>> --
>> mikeaj72
>> ------------------------------------------------------------------------
>> mikeaj72's Profile: http://www.thecodecage.com/forumz/member.php?userid=46
>> View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=44176
>>
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting of text effecting formatting of background =?Utf-8?B?SEFI?= Microsoft Access Reports 6 25th Mar 2008 06:23 PM
Protect Cell Formatting including Conditional Formatting =?Utf-8?B?TWljayBKZW5uaW5ncw==?= Microsoft Excel Misc 5 13th Nov 2007 05:32 PM
Conditional Formatting No Longer Conditional in 2007 Beta =?Utf-8?B?Q2FjdHVhci1Oby1KdXRzdQ==?= Microsoft Excel Crashes 0 17th Nov 2006 10:01 PM
How do I do a complex conditional in a conditional formatting formula Ray Stevens Microsoft Excel Discussion 7 12th Mar 2006 10:24 PM
Conditional Formatting that will display conditional data =?Utf-8?B?QnJhaW5GYXJ0?= Microsoft Excel Worksheet Functions 1 13th Sep 2005 05:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:39 AM.