Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ian.UK
 
Posts: n/a
Default Conditional Formatting

Hi,

Is it possible to introduce more than 3 conditions (via conditional
formatting) onto a single spreadsheet?

I have a spreadsheet with 9 columns - the first is for name, then 1st
choice, 2nd choice etc etc...up to 8th choice. There are 8 different things
that could appear in each cell on the same row - and I would like the cell to
change colour automatically according to what appears in it. This would
obviously require 8 conditions - but I seem limited to 3.

Is there a way to increase the number of permissible conditions, or can
anyone think of a way I can achieve this without conditions?

Thanks,

Ian
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary''s Student
 
Posts: n/a
Default Conditional Formatting

This can be accomplished by using the worksheet change event. The following
macro monitors changes in A1:A20 and set the background colour:

Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("A1:A10"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Select
i = Selection.Value
With Selection.Interior
.ColorIndex = i
.Pattern = xlSolid
End With
Application.EnableEvents = True
End Sub

The sample macro only works with integers and assigns colours based upon the
integers. You could modify it to operate in a more general way.
__________________Have a good day!
Gary's Student


"Ian.UK" wrote:

Hi,

Is it possible to introduce more than 3 conditions (via conditional
formatting) onto a single spreadsheet?

I have a spreadsheet with 9 columns - the first is for name, then 1st
choice, 2nd choice etc etc...up to 8th choice. There are 8 different things
that could appear in each cell on the same row - and I would like the cell to
change colour automatically according to what appears in it. This would
obviously require 8 conditions - but I seem limited to 3.

Is there a way to increase the number of permissible conditions, or can
anyone think of a way I can achieve this without conditions?

Thanks,

Ian

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ian.UK
 
Posts: n/a
Default Conditional Formatting

Hi,

Thanks for the feedback - going to need a little bit more help with this
unfortunately, as macros are not my forte!

What part of this macro actually changes the colour of the cell?

And when you say integers, would this this macro actually work with letters
i.e. if I wanted to a cell containing the letter P to be red?

Many thanks,

Ian

"Gary''s Student" wrote:

This can be accomplished by using the worksheet change event. The following
macro monitors changes in A1:A20 and set the background colour:

Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("A1:A10"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Select
i = Selection.Value
With Selection.Interior
.ColorIndex = i
.Pattern = xlSolid
End With
Application.EnableEvents = True
End Sub

The sample macro only works with integers and assigns colours based upon the
integers. You could modify it to operate in a more general way.
__________________Have a good day!
Gary's Student


"Ian.UK" wrote:

Hi,

Is it possible to introduce more than 3 conditions (via conditional
formatting) onto a single spreadsheet?

I have a spreadsheet with 9 columns - the first is for name, then 1st
choice, 2nd choice etc etc...up to 8th choice. There are 8 different things
that could appear in each cell on the same row - and I would like the cell to
change colour automatically according to what appears in it. This would
obviously require 8 conditions - but I seem limited to 3.

Is there a way to increase the number of permissible conditions, or can
anyone think of a way I can achieve this without conditions?

Thanks,

Ian

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rowan Drummond
 
Posts: n/a
Default Conditional Formatting

See:

http://www.xldynamic.com/source/xld.....Download.html

Regards
Rowan

Ian.UK wrote:
Hi,

Thanks for the feedback - going to need a little bit more help with this
unfortunately, as macros are not my forte!

What part of this macro actually changes the colour of the cell?

And when you say integers, would this this macro actually work with letters
i.e. if I wanted to a cell containing the letter P to be red?

Many thanks,

Ian

"Gary''s Student" wrote:


This can be accomplished by using the worksheet change event. The following
macro monitors changes in A1:A20 and set the background colour:

Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("A1:A10"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Select
i = Selection.Value
With Selection.Interior
.ColorIndex = i
.Pattern = xlSolid
End With
Application.EnableEvents = True
End Sub

The sample macro only works with integers and assigns colours based upon the
integers. You could modify it to operate in a more general way.
__________________Have a good day!
Gary's Student


"Ian.UK" wrote:


Hi,

Is it possible to introduce more than 3 conditions (via conditional
formatting) onto a single spreadsheet?

I have a spreadsheet with 9 columns - the first is for name, then 1st
choice, 2nd choice etc etc...up to 8th choice. There are 8 different things
that could appear in each cell on the same row - and I would like the cell to
change colour automatically according to what appears in it. This would
obviously require 8 conditions - but I seem limited to 3.

Is there a way to increase the number of permissible conditions, or can
anyone think of a way I can achieve this without conditions?

Thanks,

Ian

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary''s Student
 
Posts: n/a
Default Conditional Formatting

Then a small update:

Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim i As String
If Intersect(Range("A1:A10"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Select
i = Selection.Value
If i = "p" Then
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End If
Application.EnableEvents = True
End Sub

Here we are only looking for the user to enter p. The colorindex=3 sets the
background colour to red. If you want other letters to trigger other
colours, then replicate the IF structure with a different letter and a
different colorindex.


With regard to entering and using this type of macro, see:


http://www.mvps.org/dmcritchie/excel/event.htm
--
Gary''s Student


"Ian.UK" wrote:

Hi,

Thanks for the feedback - going to need a little bit more help with this
unfortunately, as macros are not my forte!

What part of this macro actually changes the colour of the cell?

And when you say integers, would this this macro actually work with letters
i.e. if I wanted to a cell containing the letter P to be red?

Many thanks,

Ian

"Gary''s Student" wrote:

This can be accomplished by using the worksheet change event. The following
macro monitors changes in A1:A20 and set the background colour:

Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("A1:A10"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Select
i = Selection.Value
With Selection.Interior
.ColorIndex = i
.Pattern = xlSolid
End With
Application.EnableEvents = True
End Sub

The sample macro only works with integers and assigns colours based upon the
integers. You could modify it to operate in a more general way.
__________________Have a good day!
Gary's Student


"Ian.UK" wrote:

Hi,

Is it possible to introduce more than 3 conditions (via conditional
formatting) onto a single spreadsheet?

I have a spreadsheet with 9 columns - the first is for name, then 1st
choice, 2nd choice etc etc...up to 8th choice. There are 8 different things
that could appear in each cell on the same row - and I would like the cell to
change colour automatically according to what appears in it. This would
obviously require 8 conditions - but I seem limited to 3.

Is there a way to increase the number of permissible conditions, or can
anyone think of a way I can achieve this without conditions?

Thanks,

Ian



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ian.UK
 
Posts: n/a
Default Conditional Formatting

Hi again,

Ok, well this seems to be working better, thanks very much so far!

A couple of further problems though I am afraid.

Firstly, when I apply this code a cell in the range does go red when I type
in a 'P'. However if I delete the 'P' the cell stays red even though it is
empty. I'd like it to go to white again, but am unsure about what code would
allow me to do this?

Secondly, if I select a number of cells from the range at the same time and
delete the contents, I get run time error '13' (Type Mismatch). When
debugged, this highlights the line of code "i = Selection.Value" as the
problem.

Help with either of these problems would be really appreciated.

Many thanks again,

Ian

"Gary''s Student" wrote:

Then a small update:

Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim i As String
If Intersect(Range("A1:A10"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Select
i = Selection.Value
If i = "p" Then
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End If
Application.EnableEvents = True
End Sub

Here we are only looking for the user to enter p. The colorindex=3 sets the
background colour to red. If you want other letters to trigger other
colours, then replicate the IF structure with a different letter and a
different colorindex.


With regard to entering and using this type of macro, see:


http://www.mvps.org/dmcritchie/excel/event.htm
--
Gary''s Student


"Ian.UK" wrote:

Hi,

Thanks for the feedback - going to need a little bit more help with this
unfortunately, as macros are not my forte!

What part of this macro actually changes the colour of the cell?

And when you say integers, would this this macro actually work with letters
i.e. if I wanted to a cell containing the letter P to be red?

Many thanks,

Ian

"Gary''s Student" wrote:

This can be accomplished by using the worksheet change event. The following
macro monitors changes in A1:A20 and set the background colour:

Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("A1:A10"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Select
i = Selection.Value
With Selection.Interior
.ColorIndex = i
.Pattern = xlSolid
End With
Application.EnableEvents = True
End Sub

The sample macro only works with integers and assigns colours based upon the
integers. You could modify it to operate in a more general way.
__________________Have a good day!
Gary's Student


"Ian.UK" wrote:

Hi,

Is it possible to introduce more than 3 conditions (via conditional
formatting) onto a single spreadsheet?

I have a spreadsheet with 9 columns - the first is for name, then 1st
choice, 2nd choice etc etc...up to 8th choice. There are 8 different things
that could appear in each cell on the same row - and I would like the cell to
change colour automatically according to what appears in it. This would
obviously require 8 conditions - but I seem limited to 3.

Is there a way to increase the number of permissible conditions, or can
anyone think of a way I can achieve this without conditions?

Thanks,

Ian

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rowan Drummond
 
Posts: n/a
Default Conditional Formatting

Try this adaption:

Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo ErrorHandler
Dim cell As Range
Application.EnableEvents = False
If Not Intersect(Range("A1:A10"), Target) Is Nothing Then
For Each cell In Intersect(Range("A1:A10"), Target)
If cell.Value = "p" Then
cell.Interior.ColorIndex = 3
Else
cell.Interior.ColorIndex = xlNone
End If
Next cell
End If

ErrorHandler:
Application.EnableEvents = True
End Sub

Hope this helps
Rowan

Ian.UK wrote:
Hi again,

Ok, well this seems to be working better, thanks very much so far!

A couple of further problems though I am afraid.

Firstly, when I apply this code a cell in the range does go red when I type
in a 'P'. However if I delete the 'P' the cell stays red even though it is
empty. I'd like it to go to white again, but am unsure about what code would
allow me to do this?

Secondly, if I select a number of cells from the range at the same time and
delete the contents, I get run time error '13' (Type Mismatch). When
debugged, this highlights the line of code "i = Selection.Value" as the
problem.

Help with either of these problems would be really appreciated.

Many thanks again,

Ian

"Gary''s Student" wrote:


Then a small update:

Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim i As String
If Intersect(Range("A1:A10"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Select
i = Selection.Value
If i = "p" Then
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End If
Application.EnableEvents = True
End Sub

Here we are only looking for the user to enter p. The colorindex=3 sets the
background colour to red. If you want other letters to trigger other
colours, then replicate the IF structure with a different letter and a
different colorindex.


With regard to entering and using this type of macro, see:


http://www.mvps.org/dmcritchie/excel/event.htm
--
Gary''s Student


"Ian.UK" wrote:


Hi,

Thanks for the feedback - going to need a little bit more help with this
unfortunately, as macros are not my forte!

What part of this macro actually changes the colour of the cell?

And when you say integers, would this this macro actually work with letters
i.e. if I wanted to a cell containing the letter P to be red?

Many thanks,

Ian

"Gary''s Student" wrote:


This can be accomplished by using the worksheet change event. The following
macro monitors changes in A1:A20 and set the background colour:

Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("A1:A10"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Select
i = Selection.Value
With Selection.Interior
.ColorIndex = i
.Pattern = xlSolid
End With
Application.EnableEvents = True
End Sub

The sample macro only works with integers and assigns colours based upon the
integers. You could modify it to operate in a more general way.
__________________Have a good day!
Gary's Student


"Ian.UK" wrote:


Hi,

Is it possible to introduce more than 3 conditions (via conditional
formatting) onto a single spreadsheet?

I have a spreadsheet with 9 columns - the first is for name, then 1st
choice, 2nd choice etc etc...up to 8th choice. There are 8 different things
that could appear in each cell on the same row - and I would like the cell to
change colour automatically according to what appears in it. This would
obviously require 8 conditions - but I seem limited to 3.

Is there a way to increase the number of permissible conditions, or can
anyone think of a way I can achieve this without conditions?

Thanks,

Ian

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 Error ddate Excel Worksheet Functions 0 May 5th 05 09:00 PM
difficulty with conditional formatting Deb Excel Discussion (Misc queries) 0 March 23rd 05 06:13 PM
conditional formatting question Deb Excel Discussion (Misc queries) 0 March 23rd 05 02:07 AM
Determine cells that drive conditional formatting? Nicolle K. Excel Discussion (Misc queries) 2 January 7th 05 01:08 AM
Conditional formatting not available in Excel BAB Excel Discussion (Misc queries) 2 January 1st 05 03:33 PM


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