Speed up Color Changing

tmo4ever

New Member
Joined
Nov 7, 2005
Messages
49
Can anyone help with this?

I have a Gantt chart that I'm building. Since I need to have 4 color options, I can't use conditional formatting, so I'm using a great script that erik.van.geit came up with.

Is there a quicker way to have to code only make changes to each row rather than the whole range? It can take several seconds to update because of the number of cells.


Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim WatchRange As Range
Dim cell As Range
Dim colors As Variant
Set WatchRange = Range("k7:ip40")
colors = Array("2", "36", "50", "41", "3")

For Each cell In WatchRange
  If cell <> "" And IsNumeric(cell) Then
  cell.Interior.ColorIndex = colors(cell.Value)
  If cell.Value <> 0 Then cell.Font.ColorIndex = colors(cell.Value)
  End If
Next cell
End Sub

Any help would be great!

Thanks!
 
just_jon said:
In row 2 of the sample you sent, is there any reason not to date dates by day seeded there?

No, that was just the nest way I knew how to set it up so the weekends wouldn't be calculated.
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,214,907
Messages
6,122,181
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top