Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Code to change interior colour only if current interior colour is

Hi all
I need a code that finds cells on the current worksheet that are currently
set with an interior colour index of 36, and reset them to be xlnone.
By doing so I'm getting rid of standard shading but keeping user applied
colours.

I tried to do the following but it doesn't apply to all cells???

Sub NoYellowshading()
Dim lastrow, crow As Long
Dim r As Range
lastrow = ActiveSheet.Cells(Rows.Count, "a").End(xlUp).Row
Range("A1:BY" & lastrow).Select
If Selection.Interior.ColorIndex = 36 Then
Selection.Interior.ColorIndex = xlNone
End If
End Sub

Any help greatly appreciated.
--
Thank for your help
BeSmart
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Code to change interior colour only if current interior colour is

Sub NoYellowshading()
Dim lastrow, crow As Long
Dim r As Range
Dim cell As Range
lastrow = ActiveSheet.Cells(Rows.Count, "a").End(xlUp).Row
For Each cell In Range("A1:BY" & lastrow).
If cell.Interior.ColorIndex = 36 Then
cell.Interior.ColorIndex = xlNone
End If
Next cell
End Sub

--

HTH

RP

"BeSmart" wrote in message
...
Hi all
I need a code that finds cells on the current worksheet that are currently
set with an interior colour index of 36, and reset them to be xlnone.
By doing so I'm getting rid of standard shading but keeping user applied
colours.

I tried to do the following but it doesn't apply to all cells???

Sub NoYellowshading()
Dim lastrow, crow As Long
Dim r As Range
lastrow = ActiveSheet.Cells(Rows.Count, "a").End(xlUp).Row
Range("A1:BY" & lastrow).Select
If Selection.Interior.ColorIndex = 36 Then
Selection.Interior.ColorIndex = xlNone
End If
End Sub

Any help greatly appreciated.
--
Thank for your help
BeSmart



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Code to change interior colour only if current interior colour is

I don't follow the distinction of "getting rid of standard
shading but keeping user applied colours" but have a go
with this:

Sub NoYellowshading2()
Dim r As Range
For Each r In ActiveSheet.UsedRange
If r.Interior.ColorIndex = 36 Then
r.Interior.ColorIndex = xlNone
End If
Next
End Sub

UsedRange assumes you mean ALL cells.

Regards,
Peter

-----Original Message-----
Hi all
I need a code that finds cells on the current worksheet

that are currently
set with an interior colour index of 36, and reset them

to be xlnone.
By doing so I'm getting rid of standard shading but

keeping user applied
colours.

I tried to do the following but it doesn't apply to all

cells???

Sub NoYellowshading()
Dim lastrow, crow As Long
Dim r As Range
lastrow = ActiveSheet.Cells(Rows.Count, "a").End(xlUp).Row
Range("A1:BY" & lastrow).Select
If Selection.Interior.ColorIndex = 36 Then
Selection.Interior.ColorIndex = xlNone
End If
End Sub

Any help greatly appreciated.
--
Thank for your help
BeSmart
.

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
current date it should intimate cheques due by colour change mas Excel Discussion (Misc queries) 1 June 10th 07 09:50 AM
change a cell background colour to my own RGB colour requirements Stephen Doughty Excel Discussion (Misc queries) 4 June 16th 06 01:08 PM
Interior borders Nicole Excel Discussion (Misc queries) 5 October 17th 05 10:21 PM
Conditional Format with VBA - Interior Colour of cell based on value from in-cell dropdown Steve[_52_] Excel Programming 5 June 15th 04 11:45 AM
Is ther a way to change the interior.colorindex of multiple rows sdnicsm Excel Programming 2 April 5th 04 03:53 AM


All times are GMT +1. The time now is 04:07 PM.

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"