PC Review


Reply
Thread Tools Rate Thread

CF sheet sub modifications

 
 
Max
Guest
Posts: n/a
 
      11th Jan 2008
Seeking help to modify the sub below to conditionally format cols A to T
based on numbers in key col U (in U2:U100). Currently it CF's only the range
U2:U100. And for viewing clarity, how to add lines to the sub so that the
font color will "contrast" with the fill color (eg black font for light
fills, white for dark fills). Thanks.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("U2:U100")) Is Nothing Then
Select Case Target
Case 1 To 5
icolor = 6
Case 6 To 10
icolor = 12
Case 11 To 15
icolor = 7
Case 16 To 20
icolor = 53
Case 21 To 25
icolor = 15
Case 26 To 30
icolor = 42
Case Else
'Whatever
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub


 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      11th Jan 2008
Max,

Try this. With regard to font colour that's largely subjective so I'll leave
it to you to pick the colour you want. All are currently set to black.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("U2:U100")) Is Nothing Then
Select Case Target
Case 1 To 5
icolor = 6
fcolor = 1
Case 6 To 10
icolor = 12
fcolor = 1
Case 11 To 15
icolor = 7
fcolor = 1
Case 16 To 20
icolor = 53
fcolor = 1
Case 21 To 25
icolor = 15
fcolor = 1
Case 26 To 30
icolor = 42
fcolor = 1
Case Else
End Select
With Target
.Offset(0, -20).Resize(1, 20).Interior.ColorIndex = icolor
.Offset(0, -20).Resize(1, 20).Font.ColorIndex = fcolor
End With
End If
End Sub


Mike

"Max" wrote:

> Seeking help to modify the sub below to conditionally format cols A to T
> based on numbers in key col U (in U2:U100). Currently it CF's only the range
> U2:U100. And for viewing clarity, how to add lines to the sub so that the
> font color will "contrast" with the fill color (eg black font for light
> fills, white for dark fills). Thanks.
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Dim icolor As Integer
> If Not Intersect(Target, Range("U2:U100")) Is Nothing Then
> Select Case Target
> Case 1 To 5
> icolor = 6
> Case 6 To 10
> icolor = 12
> Case 11 To 15
> icolor = 7
> Case 16 To 20
> icolor = 53
> Case 21 To 25
> icolor = 15
> Case 26 To 30
> icolor = 42
> Case Else
> 'Whatever
> End Select
> Target.Interior.ColorIndex = icolor
> End If
> End Sub
>
>
>

 
Reply With Quote
 
Max
Guest
Posts: n/a
 
      11th Jan 2008
Mike, thanks for your help. It works good, and you've also shown the way to
manipulate the font color. I'll tinker with it.



 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      11th Jan 2008
Your welcome and thanks for the feedback

"Max" wrote:

> Mike, thanks for your help. It works good, and you've also shown the way to
> manipulate the font color. I'll tinker with it.
>
>
>
>

 
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
modifications =?Utf-8?B?RW1pbHkgU29laG5lcg==?= Microsoft Word Document Management 1 13th Oct 2007 06:55 PM
Do not allow modifications pammy via AccessMonster.com Microsoft Access Forms 2 13th Apr 2007 02:17 PM
Back End Modifications =?Utf-8?B?ZXJpa19ncmVnb3J5?= Microsoft Word Document Management 1 19th May 2006 10:00 AM
Password for Modifications =?Utf-8?B?Um9kc21hbg==?= Microsoft Word New Users 0 11th May 2005 08:37 PM
Saving Modifications to a style sheet LB Microsoft Frontpage 3 23rd Oct 2003 04:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:27 PM.