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

I pickedup the following code from
http://www.ozgrid.com/VBA/excel-cond...ting-limit.htm

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("A1:A10")) 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
-------------------
This works real well


How can I make this work with a Worksheet_Calculate subroutine?

I tried to play with it but could not make it work. I have a rather
large range of temperature values I would like to color as I change
different parameters.

Thanks for any help.

JDB

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Excel Conditional Formatting

Why would you want to? With calculate, you would need to check each cell,
each value. Not as efficient.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"JDB" wrote in message
oups.com...
I pickedup the following code from
http://www.ozgrid.com/VBA/excel-cond...ting-limit.htm

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("A1:A10")) 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
-------------------
This works real well


How can I make this work with a Worksheet_Calculate subroutine?

I tried to play with it but could not make it work. I have a rather
large range of temperature values I would like to color as I change
different parameters.

Thanks for any help.

JDB



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Excel Conditional Formatting

Here is my problem;
1. I have a finite difference analysis of fish temperatures -
2. Internal portions depend on exteranl temp and time in the oven
3. I want different colors to dispay different temp ranges
4. the Worksheet_change works if I directly enter the data but I have
something like 18,000 cells recalculating when I change a parameter.

What can you suggest that is more efficient than a re-calcuation event?

Thanks


JDB

Bob Phillips wrote:
Why would you want to? With calculate, you would need to check each cell,
each value. Not as efficient.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Excel Conditional Formatting

With Calculate, you will get 18,000 recalculating for every cell change. It
can only be slower.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"JDB" wrote in message
oups.com...
Here is my problem;
1. I have a finite difference analysis of fish temperatures -
2. Internal portions depend on exteranl temp and time in the oven
3. I want different colors to dispay different temp ranges
4. the Worksheet_change works if I directly enter the data but I have
something like 18,000 cells recalculating when I change a parameter.

What can you suggest that is more efficient than a re-calcuation event?

Thanks


JDB

Bob Phillips wrote:
Why would you want to? With calculate, you would need to check each

cell,
each value. Not as efficient.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Excel Conditional Formatting

Thanks your good advice.
I simply wrote a macro that runs from a command button to run the
conditional formatting code in question. 18,000 cell in about 4 sec,
so I can handle that.

JDB

For the record and anyone else looking at this, I am a hacker, but this
works for me.
-------------------------------
Private Sub CommandButton1_Click()
Call ConditionalFormat
End Sub


Private Sub ConditionalFormat()
Dim icolor As Integer
Dim R As Integer
Dim C As Integer

RangeName = "DataMatrix"

FCol = Range(RangeName).Column
FRow = Range(RangeName).Row

For R = FRow To 3200 Step 1
If Cells(R, FCol) = "" Then
Exit For
End If
For C = FCol To 64 Step 1
If Cells(R, C) = "" Then
Exit For
End If
TargetCell = Round(Cells(R, C), 0)

Select Case TargetCell
Case 0 To 28
icolor = 37
Case 29 To 60
icolor = 41
Case 61 To 90
icolor = 39
Case 91 To 120
icolor = 43
Case 121 To 150
icolor = 6
Case 151 To 180
icolor = 46
Case Else
icolor = 3
End Select

Cells(R, C).Interior.ColorIndex = icolor

Next C
Next R

End Sub
-----------------------------------------------






Bob Phillips wrote:
With Calculate, you will get 18,000 recalculating for every cell change. It
can only be slower.

--

HTH

Bob Phillips




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 in Excel Brian New Users to Excel 4 December 10th 09 08:40 PM
Excel conditional formatting Lewy Excel Worksheet Functions 3 August 24th 09 05:06 PM
Conditional Formatting in Excel Yossy Excel Worksheet Functions 1 October 31st 08 06:10 AM
conditional formatting in excel Pritchett Excel Worksheet Functions 3 March 27th 06 11:37 AM
Conditional Formatting in Excel BaptistKitty Excel Worksheet Functions 2 February 5th 06 06:33 PM


All times are GMT +1. The time now is 08:58 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"