Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Conditional Formatting - Range

How can I make the color coding apply to the cell as well as the next 9
columns in that row.



Private Sub Worksheet_Change(ByVal Target As Range)
Dim WatchRange As Range
Dim CellVal As String
If Target.Cells.Count 1 Then Exit Sub
If Target = "" Then Exit Sub
CellVal = Target
Set WatchRange = Range("A1:c100") 'change to suit

If Not Intersect(Target, WatchRange) Is Nothing Then
Select Case CellVal
Case "Sheraton"
Target.Interior.ColorIndex = 18
Case "Covance"
Target.Interior.ColorIndex = 10
Case "Cronkite"
Target.Interior.ColorIndex = 6
Case "Intel"
Target.Interior.ColorIndex = 46
Case "Other"
Target.Interior.ColorIndex = 45
Case "Freescale"
Target.Interior.ColorIndex = 32
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Conditional Formatting - Range

Hi Monica,

Range(Target, Target.Offset(0, 9)).Interior.ColorIndex = 18

Regards,

OssieMac

"Monica" wrote:

How can I make the color coding apply to the cell as well as the next 9
columns in that row.



Private Sub Worksheet_Change(ByVal Target As Range)
Dim WatchRange As Range
Dim CellVal As String
If Target.Cells.Count 1 Then Exit Sub
If Target = "" Then Exit Sub
CellVal = Target
Set WatchRange = Range("A1:c100") 'change to suit

If Not Intersect(Target, WatchRange) Is Nothing Then
Select Case CellVal
Case "Sheraton"
Target.Interior.ColorIndex = 18
Case "Covance"
Target.Interior.ColorIndex = 10
Case "Cronkite"
Target.Interior.ColorIndex = 6
Case "Intel"
Target.Interior.ColorIndex = 46
Case "Other"
Target.Interior.ColorIndex = 45
Case "Freescale"
Target.Interior.ColorIndex = 32

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Conditional Formatting - Range

I didn't test this but it should work.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim WatchRange As Range
Dim CellVal As String
If Target.Cells.Count 1 Then Exit Sub
If Target = "" Then Exit Sub
CellVal = Target
Set WatchRange = Range("A1:c100") 'change to suit
Set cRng = Range(Target.Offset(0, 0), Target.Offset(0, 9))
If Not Intersect(Target, WatchRange) Is Nothing Then
Select Case CellVal
Case "Sheraton"
cRng.Interior.ColorIndex = 18
Case "Covance"
cRng.Interior.ColorIndex = 10
Case "Cronkite"
cRng.Interior.ColorIndex = 6
Case "Intel"
cRng.Interior.ColorIndex = 46
Case "Other"
cRng.Interior.ColorIndex = 45
Case "Freescale"


"Monica" wrote:

How can I make the color coding apply to the cell as well as the next 9
columns in that row.



Private Sub Worksheet_Change(ByVal Target As Range)
Dim WatchRange As Range
Dim CellVal As String
If Target.Cells.Count 1 Then Exit Sub
If Target = "" Then Exit Sub
CellVal = Target
Set WatchRange = Range("A1:c100") 'change to suit

If Not Intersect(Target, WatchRange) Is Nothing Then
Select Case CellVal
Case "Sheraton"
Target.Interior.ColorIndex = 18
Case "Covance"
Target.Interior.ColorIndex = 10
Case "Cronkite"
Target.Interior.ColorIndex = 6
Case "Intel"
Target.Interior.ColorIndex = 46
Case "Other"
Target.Interior.ColorIndex = 45
Case "Freescale"
Target.Interior.ColorIndex = 32

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Conditional Formatting - Range

You might not need to use the Set since the range changes with the target.

"Monica" wrote:

How can I make the color coding apply to the cell as well as the next 9
columns in that row.



Private Sub Worksheet_Change(ByVal Target As Range)
Dim WatchRange As Range
Dim CellVal As String
If Target.Cells.Count 1 Then Exit Sub
If Target = "" Then Exit Sub
CellVal = Target
Set WatchRange = Range("A1:c100") 'change to suit

If Not Intersect(Target, WatchRange) Is Nothing Then
Select Case CellVal
Case "Sheraton"
Target.Interior.ColorIndex = 18
Case "Covance"
Target.Interior.ColorIndex = 10
Case "Cronkite"
Target.Interior.ColorIndex = 6
Case "Intel"
Target.Interior.ColorIndex = 46
Case "Other"
Target.Interior.ColorIndex = 45
Case "Freescale"
Target.Interior.ColorIndex = 32

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting for a Range KKD New Users to Excel 2 April 1st 10 04:12 AM
Conditional Formatting with range Keyrookie Excel Worksheet Functions 2 December 3rd 09 02:20 PM
Conditional Formatting with range Keyrookie Excel Worksheet Functions 3 December 1st 09 02:22 PM
conditional formatting using a range Marc's NYK Excel Discussion (Misc queries) 1 August 14th 09 04:00 PM
Conditional Formatting for a Range ahishaslauer Excel Discussion (Misc queries) 2 April 3rd 06 02:29 AM


All times are GMT +1. The time now is 05:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"