Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Conditionally formatting

Can someone tell me please how I can do the following, I am trying to
conditionally format a range of cells which sum from others.

I have used the following:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Dim icolor As Integer

If Intersect(Target, Range("P3:W3000")) Is Nothing Then


Select Case Target

Case 1 To 50
icolor = 35

Case 51 To 100
icolor = 36

Case Is = 101
icolor = 3

Case Else
'icolor = 0

End Select

Target.Interior.ColorIndex = icolor

End If

End Sub

but this changes the cell that I am working on and not the range in the
target which is summing.

Please can someone provide me with a solution?

Many thanks

--
Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Conditionally formatting

Private Sub Worksheet_Calculate()

Dim icolor As Integer

for each cell in Range("P3:W3000")


Select Case cell

Case 1 To 50
icolor = 35

Case 51 To 100
icolor = 36

Case Is = 101
icolor = 3

Case Else
icolor = xlNone

End Select

cell.Interior.ColorIndex = icolor

End If

End Sub

Change P3:W3000 to reflect the range where you want the conditional coloring
applied. Also note that you can get up to 3 conditions (plus the default) in
the built in conditional formatting option under the format menu.

--
Regards,
Tom Ogilvy

"Mark" wrote:

Can someone tell me please how I can do the following, I am trying to
conditionally format a range of cells which sum from others.

I have used the following:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Dim icolor As Integer

If Intersect(Target, Range("P3:W3000")) Is Nothing Then


Select Case Target

Case 1 To 50
icolor = 35

Case 51 To 100
icolor = 36

Case Is = 101
icolor = 3

Case Else
'icolor = 0

End Select

Target.Interior.ColorIndex = icolor

End If

End Sub

but this changes the cell that I am working on and not the range in the
target which is summing.

Please can someone provide me with a solution?

Many thanks

--
Mark

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
conditionally formatting Art Excel Worksheet Functions 3 February 28th 10 05:08 AM
Conditionally formatting currency Yendorian Excel Worksheet Functions 3 June 15th 07 12:13 AM
Conditionally Formatting phmckeever Excel Worksheet Functions 1 August 25th 06 03:00 PM
Conditionally formatting rows junoon Excel Worksheet Functions 4 May 29th 06 10:36 PM
Conditionally formatting other cells? brett Excel Worksheet Functions 3 December 20th 05 11:09 PM


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

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"