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: 386
Default Colour format code

Hi,

I have a worksheet that I need to fill with five different colours, (none of
which are white) to represent a timeline of activities.

From cell I4 going vertically downwards I have the colours I want, blue,
green, brown, black and grey.
In cell J4 and going downwards I have the starting hours of the action
In cell K4 and going downwards I have the finishing hours for each action
Each cell going horizontally across from each line represents one hour
starting from L4, (starting from cell L2 I actually have a horizontal list
going 0, 1, 2 etc to represent the hours but I dont need this if its not
useful).

Is it possible to have a code that will fill in each cell starting from L4
with colour that is in I from the start time to the finish time. For example;

Blue 0 2 €“ excel fills in cells L4 and M4 in blue
Black 2 6 €“ excel fills in cells M5 to Q5 in black
Green 6 7 €“ excel fills in cells Q6 to R6 in green

The items that I need to keep changeable are the colours in each row, the
number of hours per task and the amount of cells that are coloured (i.e. on
some sheets there will be 10 rows coloured the others 30).

I actually have this code which works well and I can set an IF to change the
text to a number to drive the colours from, the bit I cant get is how to
make it fill more than one cell horizontally based on the start and finish
hours.

Is it possible to adapt this code to do that function?

Thanks a lot

Private Sub Worksheet_Change(ByVal Target As Range)
Set i = Range("I4:I20")
Set t = Target
If Intersect(t, i) Is Nothing Then Exit Sub
v = t.Value
If v 56 Then Exit Sub
Application.EnableEvents = False
Cells(t.Row, "L").Interior.ColorIndex = v
Cells(t.Row, "L").Font.ColorIndex = Target
Application.EnableEvents = True
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
Text format - setting text colour with code NDBC Excel Discussion (Misc queries) 6 July 1st 09 10:15 PM
Cells Won't Colour Format Jonathan Excel Discussion (Misc queries) 4 May 24th 07 04:10 PM
Format Cell Colour scottymelloty Excel Worksheet Functions 0 November 18th 04 04:08 PM
Format Cell Colour scottymelloty Excel Worksheet Functions 2 November 17th 04 08:19 PM
Code to change interior colour only if current interior colour is BeSmart Excel Programming 2 October 5th 04 12:06 AM


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