LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Need VBA for Conditional Format of Row

The only excuse I have for the following is.... it's Saturday and things are
slow.<g

I decided to investigate whether this problem could be solved without using
a loop and I came up with what follows. Strange thing is that a **quick**
test shows the following code to be equal, or perhaps possibly faster, than
the loop you posted. If anyone has a **high resolution** timer and the
time/inclination to test this out, the results might be interesting. With
that said, here is what I came up with...

Dim Addr As String, Xcol As Range, Col2Color As Range
Set Xcol = Range("H7:H700") 'Range with X's
Set Col2Color = Range("A7:G700") 'Range whose cells can be colored
Application.ScreenUpdating = False
On Error Resume Next
Addr = Xcol.SpecialCells(xlCellTypeBlanks).Address
Col2Color.Interior.ColorIndex = xlNone
Xcol.Replace "X", "", xlWhole, , True
Intersect(Col2Color, Xcol.SpecialCells(xlCellTypeBlanks). _
EntireRow).Interior.ColorIndex = 42
Xcol.SpecialCells(xlCellTypeBlanks).Value = "X"
Range(Addr).Value = ""
Intersect(Col2Color, Range(Addr).EntireRow).Interior.ColorIndex = xlNone
Application.ScreenUpdating = True

--
Rick (MVP - Excel)



"Don Guillett" wrote in message
...
for each c in range("h7:h700")
if ucase(c)="X" then rows(c.row).interior.colorindex=42
next c

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"DanielleVBANewbie" wrote in
message ...
Hi guys,

I need VBA code to add to an existing macro. If column H has an "x" in
it
then I need that entire row highlighed as color 42 (light blue). Below
is
what I tried but it isn't working. Any help would be appreciated.

Dim cfrange As range
Set cfrange = range("h7:h700")
If cfrange = "x" Then
range("A:G").Interior.ColorIndex = 42
End If

--
Danielle :<)


 
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
Excel 2003 : conditional format for 5 format settings Luc[_7_] Excel Programming 1 January 7th 10 09:07 PM
Conditional Format overwrighting previous conditional format davethewelder Excel Programming 2 April 10th 08 04:01 PM
New Conditional Format Overriding Previous Conditional Format Rene Excel Discussion (Misc queries) 3 February 27th 08 06:08 PM
Multiple conditional on conditional format formula Bob Phillips[_7_] Excel Programming 0 July 27th 04 05:30 PM
Keep format after paste from other worksheets - conditional format or EnableControl solution doesn't work No Name Excel Programming 0 May 3rd 04 12:22 PM


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