Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 334
Default Automatically color merged cells

Using Excel '07, I'm trying to automatically highlight a list of vertically
merged cells the same color as their unmerged rows next to them. For example:

Column A might have cells A2-A5 merged, while cells B2-B5 are not. I'd like
the entire row(s) all the same color, and the next merged set a different
color (A6-A7 merged, with B2-B7 not). Is this possible to do automatically?
Automatic table formatting will unmerge cells in column A and alternately
color each individual row. I would like the groups of rows to each be
colored differently.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Automatically color merged cells

You mean like banding--red, yellow, red, yellow, red, yellow????

If yes, then you could use something like:

Option Explicit
Sub testme()
Dim wks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim myColor As Long

Set wks = Worksheets("Sheet1")

With wks
FirstRow = 1
LastRow = .Cells(.Rows.Count, "a").End(xlUp).Row

iRow = FirstRow
myColor = 3
Do
If iRow LastRow Then
Exit Do
End If

.Cells(iRow, "A").MergeArea.EntireRow.Interior.ColorIndex = myColor

iRow = iRow + .Cells(iRow, "A").MergeArea.Rows.Count

If myColor = 3 Then
myColor = 6
Else
myColor = 3
End If
Loop
End With
End Sub

If you don't like those colors, record a macro when you change the fill to
colors that you do like and substitute them in the code (4 places!).



Rick wrote:

Using Excel '07, I'm trying to automatically highlight a list of vertically
merged cells the same color as their unmerged rows next to them. For example:

Column A might have cells A2-A5 merged, while cells B2-B5 are not. I'd like
the entire row(s) all the same color, and the next merged set a different
color (A6-A7 merged, with B2-B7 not). Is this possible to do automatically?
Automatic table formatting will unmerge cells in column A and alternately
color each individual row. I would like the groups of rows to each be
colored differently.

Thanks


--

Dave Peterson
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
Automatically Adjusting Row Height in Merged Cells MGC Excel Discussion (Misc queries) 12 October 1st 07 08:19 PM
row height increase automatically to fit contents of merged cells JB Excel Discussion (Misc queries) 1 May 22nd 07 07:37 PM
Automatically re-sizing merged cells LongTermNoob Excel Worksheet Functions 1 March 28th 07 10:42 AM
How can I automatically expand merged cells to fit text in excel Michelle Bance Excel Discussion (Misc queries) 1 February 19th 07 02:19 PM
automatically fit an image into merged cells dave Excel Discussion (Misc queries) 1 January 26th 05 11:54 AM


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