Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Format Cell Background on Condition

Can anyone help me with a VBA routine that will find all cells in a worksheet
that contain the string 'Member Totals' and then shade that cell and the five
adjacent cells (to the left) in grey.

I would use conditional formatting, but I have lots of merged cells so I
can't fill the formatting down.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Format Cell Background on Condition

Yet another example of why merged cells should be outlawed...

In article ,
"PCullen" wrote:

I would use conditional formatting, but I have lots of merged cells so I
can't fill the formatting down.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Format Cell Background on Condition

Sub ColorCells()
Dim c As String
Dim rng As Range
Dim sAddr As String
c = "Member Totals"
Cells.Interior.ColorIndex = xlNone
Set rng = Cells.Find(what:=c, _
After:=Range("A1"), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
sAddr = rng.Address
Do
Set rng1 = rng.MergeArea(1)
Set rng1 = rng1.Offset(0, -5).Resize(1, 6)
rng1.Interior.ColorIndex = 15
Set rng = Cells.FindNext(rng)
Loop Until rng.Address = sAddr
End If
End Sub

--
Regards,
Tom Ogilvy

"PCullen" wrote in message
...
Can anyone help me with a VBA routine that will find all cells in a

worksheet
that contain the string 'Member Totals' and then shade that cell and the

five
adjacent cells (to the left) in grey.

I would use conditional formatting, but I have lots of merged cells so I
can't fill the formatting down.



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
Condition Format with 2 cell Kim Excel Worksheet Functions 5 February 27th 09 11:07 AM
Cell format as condition mars Excel Worksheet Functions 1 November 24th 08 02:17 AM
Determining background color of cell, in &H0080FFFF& format? Don Wiss Excel Programming 2 December 25th 04 10:23 AM
Conditional format if cell=0 then font colour same as background . Paligap Excel Discussion (Misc queries) 2 December 20th 04 12:07 AM
change background color of row until condition is met fullymooned[_2_] Excel Programming 2 February 5th 04 09:20 PM


All times are GMT +1. The time now is 01:35 PM.

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"