LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Colors overridden in a Macro

Hello all,

I'm a newbie with excel, and would like to ask a question:

I was looking for a technique to paint entire rows based on the value
of a cell in that row, and found in this group the following script:

'In case cell B equals "C", paint the cell with color index 24

Sub Color_rows()
Dim FirstAddress As String
Dim myArr As Variant
Dim rng As Range
Dim I As Long


Application.ScreenUpdating = False
myArr = Array("C")
'You can also use more values in the Array
Cells.Interior.ColorIndex = xlNone
'set the fill color to "no fill" in all cells


With Range("B:B")
For I = LBound(myArr) To UBound(myArr)
Set rng = .Find(What:=myArr(I), After:=Range("B" &
Rows.Count), LookAt:=xlWhole)
'If you want to search in a part of the rng.value then use
xlPart
If Not rng Is Nothing Then
FirstAddress = rng.Address
Do
rng.EntireRow.Interior.ColorIndex = 24
'make the row red
Set rng = .FindNext(rng)
Loop While Not rng Is Nothing And rng.Address <
FirstAddress
End If
Next I
End With
Application.ScreenUpdating = True
End Sub



Now comes my question:

The above script overrides the colors of previously formatted cells, in
which the B cell doesn't contain the required condition (that is, does
not equal "C"). So, what it actually does is, it paints the rows in
which B="C", and UNpaints those who don't have the condition.

Also, when a row has the above mentioned B="C", not always the script
overrides the colors of a previously formatted cell, so I don't really
understand what is going on.

The rationalle of what I'm doing is, that I need to distinguish between
rows that contain ongoing data and rows that contain data that was
already finalized, and therefore doesn't need to have its original
colors, but to be painted in its entirety instead. On the other hand,
the above mentioned ongoing data rows, shouldn't change their colors as
a result of running the macro.

Whoever got this far,

Thanks a lot !

Sharon

 
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
Used drawing colors in shapes....lost default colors for "Fill Col Lai704 Excel Discussion (Misc queries) 1 August 20th 08 04:45 AM
What do I need to add to my macro to make the cell colors change Bojames Excel Discussion (Misc queries) 4 July 22nd 08 03:52 PM
Worksheet formatting (fill colors & text colors) disappeared sweettooth Excel Discussion (Misc queries) 2 June 24th 08 01:16 AM
Lost highlighting and font colors; background colors on web pages Jan in Raleigh Excel Discussion (Misc queries) 2 July 31st 07 09:10 PM
macro used to change colors Brian in FT W. Excel Worksheet Functions 12 June 7th 05 06:30 PM


All times are GMT +1. The time now is 09:15 AM.

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"