PC Review


Reply
Thread Tools Rate Thread

Changing all cells in one colour to a different colour

 
 
Bob
Guest
Posts: n/a
 
      25th Jun 2008
I have been provided with a workbook where alternate rows are highlighted in
a colour that makes the text difficult to read. I would like to change all
the cells with this colour to a lighter colour. Is this possible in an easy
manner?
 
Reply With Quote
 
 
 
 
Ken Johnson
Guest
Posts: n/a
 
      25th Jun 2008
On Jun 25, 7:04 pm, Bob <B...@discussions.microsoft.com> wrote:
> I have been provided with a workbook where alternate rows are highlighted in
> a colour that makes the text difficult to read. I would like to change all
> the cells with this colour to a lighter colour. Is this possible in an easy
> manner?


Conditional Formatting will override the applied fill.
If the dark rows are the odd numbered rows then use Formula Is...

=MOD(ROW(1:1),2)<>0

if it's the even numbered rows then use Formula Is...

=MOD(ROW(1:1),2)=0

and in either case apply a lighter coloured fill with the conditional
formatting.

Ken Johnson
 
Reply With Quote
 
Bob
Guest
Posts: n/a
 
      25th Jun 2008
Ken

Thanks for this. I should have looked more closely. It is not just
alternate rows. It is a number of rows with different gaps between, ie
3,5,7,12,14,etc. Your suggestion works but not for what I actually have. I
would like to identify all the cells of a particular colour wherever they
occur and then change them all. Is this possible?

"Bob" wrote:

> I have been provided with a workbook where alternate rows are highlighted in
> a colour that makes the text difficult to read. I would like to change all
> the cells with this colour to a lighter colour. Is this possible in an easy
> manner?

 
Reply With Quote
 
Ken Johnson
Guest
Posts: n/a
 
      25th Jun 2008
On Jun 25, 8:35 pm, Bob <B...@discussions.microsoft.com> wrote:
> Ken
>
> Thanks for this. I should have looked more closely. It is not just
> alternate rows. It is a number of rows with different gaps between, ie
> 3,5,7,12,14,etc. Your suggestion works but not for what I actually have. I
> would like to identify all the cells of a particular colour wherever they
> occur and then change them all. Is this possible?
>
> "Bob" wrote:
> > I have been provided with a workbook where alternate rows are highlighted in
> > a colour that makes the text difficult to read. I would like to change all
> > the cells with this colour to a lighter colour. Is this possible in an easy
> > manner?


If there are so many rows that it would take too long to Ctrl-Click
them then change there fill color then maybe run this macro to do
it...

Public Sub ChangeFill()
Dim rgDark As Range, Index As Integer, rgCell As Range
'Deal with press of Cancel Button
On Error GoTo CANCELLED
'Get user to select a cell with the dark fill
Set rgDark = Application.InputBox( _
Prompt:="Select a cell with the dark fill.", _
Title:="Lighten all rows with selected fill.", _
Default:=Selection.Cells(1).Address, _
Type:=8)
'Get the dark fill's ColorIndex
Index = rgDark.Interior.ColorIndex
'Reset for errors
On Error GoTo 0
'Find bottommost row in Column A with data
'Change the A's if column A is
'not part of the data
Dim lnLastrow As Long
lnLastrow = Range("A" & _
Range("A:A").Rows.Count).End(xlUp).Row
'Loop through column A cells and change
'dark rows to Tan (ColorIndex = 40)
Application.ScreenUpdating = False
For Each rgCell In Range("A1:A" & lnLastrow)
If rgCell.Interior.ColorIndex = Index Then
'Edit the ColorIndex value in next line
'to suit your needs.
'Run Public Sub FillColors() on a spare sheet
'to see the colors and corresponding ColorIndices
'in column A of the spare sheet
Let rgCell.EntireRow.Interior.ColorIndex = 40 'Tan
End If
Next rgCell
CANCELLED: 'User clicked Cancel button
End Sub

Following macro only need be used if Tan is not a suitable fill color
to change to.
If you run it on a spare empty sheet you will be able to see
ColorIndex value in column A and resulting color in Column B.

Public Sub FillColors()
For i = 0 To 56
With Range("A" & i + 1)
.Value = i
.Offset(0, 1).Interior.ColorIndex = i
End With
Next
End Sub


Ken Johnson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tracking changes - author colour colour changing bradsmih Microsoft Word Document Management 5 25th Jan 2010 02:36 AM
Changing fill colour of cells in a range Paul Hyett Microsoft Excel Misc 8 14th Jul 2007 07:04 PM
xl 2000 - changing chart colour doesn't update legend colour insert your name here Microsoft Excel Discussion 2 10th Sep 2006 09:25 AM
Changing font colour in some cells =?Utf-8?B?RGkgVw==?= Microsoft Excel New Users 4 12th Mar 2006 05:58 PM
Problem changing a cells colour Simon Harvey Microsoft Access 2 19th Feb 2004 12:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:06 PM.