Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Changing Colours on Worksheet

Hi

I have a worksheet which is colour coded, Is it possible
to change all cells that are highlighter say yellow to
blue?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Changing Colours on Worksheet

Jahson,

Select al of the cells to be checked (it doesn't have to be just the
coloured cell;s), and run this code

Dim cell As Range

For Each cell In Selection
With cell.Interior
If .ColorIndex = 6 Then
.ColorIndex = 5
End If
End With
Next cell

note that this will not work for conditionally formatted cells.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jahson" wrote in message
...
Hi

I have a worksheet which is colour coded, Is it possible
to change all cells that are highlighter say yellow to
blue?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Changing Colours on Worksheet

Following code will select ALL cells with yellow background...

You can now choose to do some other thing with the range instead of
selection or after selection

Sub color_find()
Dim cell, rng As Range

For Each cell In ActiveSheet.UsedRange
If cell.Interior.ColorIndex = 6 Then
If rng Is Nothing Then
Set rng = Range(cell.Address)
Else
Set rng = Union(Range(rng.Address), Range(cell.Address))
End If
End If
Next cell
rng.Select
End Sub


Jahson wrote:

Hi

I have a worksheet which is colour coded, Is it possible
to change all cells that are highlighter say yellow to
blue?

Thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Changing Colours on Worksheet

if you have a reference to a range, why convert it to an address, then back
to a range. Additionally, I think this will cause problems for a range with
many areas becuase of string length limitations:

also
Dim cell, rng As Range

dimensions cell as Variant, rng as Range
This is obviously not what you intended

Sub color_find()
Dim cell as Range, rng As Range

For Each cell In ActiveSheet.UsedRange
If cell.Interior.ColorIndex = 6 Then
If rng Is Nothing Then
Set rng = cell
Else
Set rng = Union(rng, cell)
End If
End If
Next cell
rng.Select
End Sub

--
Regards,
Tom Ogilvy



"yogendra joshi" wrote in message
...
Following code will select ALL cells with yellow background...

You can now choose to do some other thing with the range instead of
selection or after selection

Sub color_find()
Dim cell, rng As Range

For Each cell In ActiveSheet.UsedRange
If cell.Interior.ColorIndex = 6 Then
If rng Is Nothing Then
Set rng = Range(cell.Address)
Else
Set rng = Union(Range(rng.Address), Range(cell.Address))
End If
End If
Next cell
rng.Select
End Sub


Jahson wrote:

Hi

I have a worksheet which is colour coded, Is it possible
to change all cells that are highlighter say yellow to
blue?

Thanks




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
Changing Tab Colours BOXMAN Excel Worksheet Functions 2 August 24th 06 01:59 AM
Changing colours by conditions duncan79 Excel Discussion (Misc queries) 3 May 17th 06 08:26 PM
Changing Colours With Protection xander1987 Excel Discussion (Misc queries) 3 September 20th 05 05:53 PM
Changing colours in chart witzman Charts and Charting in Excel 2 May 31st 05 06:58 AM
multiple or changing colours in a data table on an excel chart fo. Kerri Buxton Charts and Charting in Excel 2 December 23rd 04 07:39 PM


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