LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Conditonal Formatting VB Code?

I've been able to created the following VB code, but it takes almost 30 seconds or more to run when the worksheet is activated. I need to know if there is a better way or place to run the code? It would be great if I could get it to run whenever a cell value is changed to Red, Blue, Green, or Amber. I want to use this in a spreadsheet for project milestones ranked as RAG or Blue that are imported from a MS Project Plan file. I've tried to use the same code with another module, Private Sub Worksheet_Calculate(), but it still takes to long to run. What is the fastest way that I can make this code run?

Private Sub Worksheet_Activate()

Dim oCell As Range

For Each oCell In Range("N17:N151")
Select Case oCell.Value
Case "Red"
oCell.Interior.ColorIndex = 3
oCell.Font.ColorIndex = 1
oCell.Font.Bold = True
Case "Blue"
oCell.Interior.ColorIndex = 5
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True
Case "Green"
oCell.Interior.ColorIndex = 4
oCell.Font.ColorIndex = 1
oCell.Font.Bold = True
Case "Amber"
oCell.Interior.ColorIndex = 6
oCell.Font.ColorIndex = 1
oCell.Font.Bold = True
Case "Complete"
oCell.Interior.ColorIndex = 1
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True
End Select
Next oCell

For Each oCell In Range("BF261:BF276")
Select Case oCell.Value
Case "Red"
oCell.Interior.ColorIndex = 3
oCell.Font.ColorIndex = 1
oCell.Font.Bold = True
Case "Blue"
oCell.Interior.ColorIndex = 5
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True
Case "Green"
oCell.Interior.ColorIndex = 4
oCell.Font.ColorIndex = 1
oCell.Font.Bold = True
Case "Amber"
oCell.Interior.ColorIndex = 6
oCell.Font.ColorIndex = 1
oCell.Font.Bold = True
Case "Complete"
oCell.Interior.ColorIndex = 1
oCell.Font.ColorIndex = 2
oCell.Font.Bold = True
End Select
Next oCell

End Sub

 
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
Conditonal formatting SunshineinFt.Myers[_2_] Excel Worksheet Functions 4 March 9th 09 05:23 PM
Conditonal Formatting TSK Excel Worksheet Functions 2 May 7th 08 10:33 AM
conditonal formatting in VB JBW Excel Worksheet Functions 2 October 12th 07 05:02 PM
Conditonal formatting Hawksby Excel Discussion (Misc queries) 2 March 9th 07 01:49 PM
Conditonal Formatting Matt Excel Discussion (Misc queries) 3 April 21st 06 07:42 PM


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

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

About Us

"It's about Microsoft Excel"