Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Colour and Pattern Formatting Cells

I've got a list of 37 condition statements which i've combined into a
valdiated drop down list, but I need the cell adjacent to the list to dispaly
one of 37 unique colour a pattern combinations to allow mutiple selections on
the sheet to be easily read to assess commonality. Any sugestions as to how I
do this, I'm pretty new to VB in Excel2003.

Simplest case is an 8Rx2C matrix with column 1 being the output in terms of
shading and patterns and column 2 being the drop down selection.

Thanks for any help
Dave
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default Colour and Pattern Formatting Cells

Just a couple of pointers:

To get code for a particular colour/pattern, just use the recorder (Tools,
Macro, Record New Macro) and tidy as necessary.

To colour according to a multiple selection, use a loop combined with If, eg:

Sub MultipleFormat()
Dim myCell As Range
For Each myCell In Selection
If myCell.Value = [...] Then
Cells(myCell.Row, 1).Font.ColorIndex = [...]
ElseIf myCell.Value = [...] Then
[...]
Else
[...]
End If
Next
End Sub

Hope that helps.

"Dave M" wrote:

I've got a list of 37 condition statements which i've combined into a
valdiated drop down list, but I need the cell adjacent to the list to dispaly
one of 37 unique colour a pattern combinations to allow mutiple selections on
the sheet to be easily read to assess commonality. Any sugestions as to how I
do this, I'm pretty new to VB in Excel2003.

Simplest case is an 8Rx2C matrix with column 1 being the output in terms of
shading and patterns and column 2 being the drop down selection.

Thanks for any help
Dave

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Colour and Pattern Formatting Cells

Hi Dave,

Following assumes you have named a range for your DV list "mylist" and a
range for your formats named "formats". The range "formats" would be in the
column left of "mylist" and same size, though it could be anywhere. Also
assumes your dropdown list is in D5 and by adjacent you mean one cell to the
right.

In the Worksheet module (rt-click sheet tab view code

Private Sub Worksheet_Change(ByVal Target As Range)
Dim vRow
Dim vClrIdx
On Error GoTo errH
If Target.Address = "$D$5" Then ' address of the DV dropdown list
vRow = Application.Match(Target.Value, Range("mylist"), 0)
If IsNumeric(vRow) Then
vClrIdx = Range("formats")(vRow, 1).Value
If IsNumeric(vClrIdx) = False Or vClrIdx < 1 Or vClrIdx 56
Then
vClrIdx = xlNone
End If
End If
Target.Offset(, 1).Interior.ColorIndex = vClrIdx
End If
errH:
End Sub

This assumes you have entered colorindex numbers in the range "formats". If
instead you have actually formated cells in "formats" you could do something
like

Target.Offset(, 1).Interior.ColorIndex = Range("formats")(vRow,
1).Colorindex
and similar for .Pattern and .PatternColorIndex if necessary.

Would need more error handling.

Regards,
Peter T

"Dave M" wrote in message
...
I've got a list of 37 condition statements which i've combined into a
valdiated drop down list, but I need the cell adjacent to the list to

dispaly
one of 37 unique colour a pattern combinations to allow mutiple selections

on
the sheet to be easily read to assess commonality. Any sugestions as to

how I
do this, I'm pretty new to VB in Excel2003.

Simplest case is an 8Rx2C matrix with column 1 being the output in terms

of
shading and patterns and column 2 being the drop down selection.

Thanks for any help
Dave



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Colour and Pattern Formatting Cells

Peter T and Martin

Many thanks, I'll give it a go, I'd got about halfway there but was stuck
for ideas!
Dave

"Peter T" wrote:

Hi Dave,

Following assumes you have named a range for your DV list "mylist" and a
range for your formats named "formats". The range "formats" would be in the
column left of "mylist" and same size, though it could be anywhere. Also
assumes your dropdown list is in D5 and by adjacent you mean one cell to the
right.

In the Worksheet module (rt-click sheet tab view code

Private Sub Worksheet_Change(ByVal Target As Range)
Dim vRow
Dim vClrIdx
On Error GoTo errH
If Target.Address = "$D$5" Then ' address of the DV dropdown list
vRow = Application.Match(Target.Value, Range("mylist"), 0)
If IsNumeric(vRow) Then
vClrIdx = Range("formats")(vRow, 1).Value
If IsNumeric(vClrIdx) = False Or vClrIdx < 1 Or vClrIdx 56
Then
vClrIdx = xlNone
End If
End If
Target.Offset(, 1).Interior.ColorIndex = vClrIdx
End If
errH:
End Sub

This assumes you have entered colorindex numbers in the range "formats". If
instead you have actually formated cells in "formats" you could do something
like

Target.Offset(, 1).Interior.ColorIndex = Range("formats")(vRow,
1).Colorindex
and similar for .Pattern and .PatternColorIndex if necessary.

Would need more error handling.

Regards,
Peter T

"Dave M" wrote in message
...
I've got a list of 37 condition statements which i've combined into a
valdiated drop down list, but I need the cell adjacent to the list to

dispaly
one of 37 unique colour a pattern combinations to allow mutiple selections

on
the sheet to be easily read to assess commonality. Any sugestions as to

how I
do this, I'm pretty new to VB in Excel2003.

Simplest case is an 8Rx2C matrix with column 1 being the output in terms

of
shading and patterns and column 2 being the drop down selection.

Thanks for any help
Dave




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 colour of cells trishb Excel Discussion (Misc queries) 2 December 12th 09 01:14 AM
colour pattern Veeshal Excel Discussion (Misc queries) 1 October 22nd 09 03:22 AM
formatting colour in cells when one cell contains a character wilko[_2_] Excel Worksheet Functions 1 September 14th 09 01:27 AM
excel 2003 - formatting cells - colour Bernard Liengme Excel Worksheet Functions 0 January 19th 09 02:40 PM
How can I count cells of a specific colour (pattern)? Nick@Durham Excel Worksheet Functions 1 November 29th 05 10:18 AM


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