Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Apply Alternate Shading to selected rows

Dear Experts:

Below macro is used to apply an alternate fill to selected cells.

I would like to get this macro changed to include also a specific fill
for a HEADER row (selected cells at the very top), ...
ie. the selected cells will also contain a header row. And these
header cells should get the following fill:
RGB(165, 165, 165), the font of this header is to be changed to bold
and font color is to be changed to white.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas


Sub AltShade_GreyRed()
Dim Counter As Integer

If MsgBox("Would you like to apply an alternate shading to
selected cells (grey/red)?", vbQuestion + vbYesNo, "Selected cells
alternate shading grey/red") = vbNo Then
Exit Sub
End If

'For every row in the current selection...
For Counter = 1 To Selection.Rows.Count
'If the row is an odd number (within the selection)...
If Counter Mod 2 = 1 Then
'Set the color to ...
Selection.Rows(Counter).Interior.Color = RGB(229, 229,
229)
'If the row is an even number (within the selection)
Else
Selection.Rows(Counter).Interior.Color = RGB(239, 211,
210)
End If
Next

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Apply Alternate Shading to selected rows

Doesn't look Grey and Red to me.
Last three lines are new.
'---
Sub AltShade_GreyRed()
Dim Counter As Integer

If MsgBox("Would you like to apply an alternate shading to selected cells (grey/red)?", _
vbQuestion + vbYesNo, "Selected cells alternate shading grey/red") = vbNo Then
Exit Sub
End If

'For every row in the current selection...
For Counter = 1 To Selection.Rows.Count
'If the row is an odd number (within the selection)...
If Counter Mod 2 = 1 Then
'Set the color to ...
Selection.Rows(Counter).Interior.Color = RGB(229, 229, 229)
'If the row is an even number (within the selection)
Else
Selection.Rows(Counter).Interior.Color = RGB(239, 211, 210)
End If
Next
Selection.Rows(1).Interior.Color = RGB(165, 165, 165)
Selection.Rows(1).Font.Bold = True
Selection.Rows(1).Font.Color = vbWhite
End Sub
--
Jim Cone
Portland, Oregon USA
http://tinyurl.com/ShadeData
(Shade Data Rows Excel add-in)

..
..
..

"andreashermle"
wrote in message
...
Dear Experts:

Below macro is used to apply an alternate fill to selected cells.

I would like to get this macro changed to include also a specific fill
for a HEADER row (selected cells at the very top), ...
ie. the selected cells will also contain a header row. And these
header cells should get the following fill:
RGB(165, 165, 165), the font of this header is to be changed to bold
and font color is to be changed to white.
Help is much appreciated. Thank you very much in advance.
Regards, Andreas


Sub AltShade_GreyRed()
Dim Counter As Integer

If MsgBox("Would you like to apply an alternate shading to
selected cells (grey/red)?", vbQuestion + vbYesNo, "Selected cells
alternate shading grey/red") = vbNo Then
Exit Sub
End If

'For every row in the current selection...
For Counter = 1 To Selection.Rows.Count
'If the row is an odd number (within the selection)...
If Counter Mod 2 = 1 Then
'Set the color to ...
Selection.Rows(Counter).Interior.Color = RGB(229, 229,
229)
'If the row is an even number (within the selection)
Else
Selection.Rows(Counter).Interior.Color = RGB(239, 211,
210)
End If
Next

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Apply Alternate Shading to selected rows

On 6 Okt., 14:26, "Jim Cone" wrote:
Doesn't look Grey and Red to me.
Last three lines are new.
'---
Sub AltShade_GreyRed()
*Dim Counter As Integer

*If MsgBox("Would you like to apply an alternate shading to selected cells (grey/red)?", _
* * vbQuestion + vbYesNo, "Selected cells alternate shading grey/red") = vbNo Then
* * *Exit Sub
*End If

*'For every row in the current selection...
*For Counter = 1 To Selection.Rows.Count
* * *'If the row is an odd number (within the selection)...
* * *If Counter Mod 2 = 1 Then
* * * * *'Set the color to ...
* * * * *Selection.Rows(Counter).Interior.Color = RGB(229, 229, 229)
* * * * *'If the row is an even number (within the selection)
* * *Else
* * * * *Selection.Rows(Counter).Interior.Color = RGB(239, 211, 210)
* * *End If
*Next
*Selection.Rows(1).Interior.Color = RGB(165, 165, 165)
*Selection.Rows(1).Font.Bold = True
*Selection.Rows(1).Font.Color = vbWhite
End Sub
--
Jim Cone
Portland, Oregon *USAhttp://tinyurl.com/ShadeData
(Shade Data Rows Excel add-in)

.
.
.

"andreashermle"
wrote in ...
Dear Experts:

Below macro is used to apply an alternate fill to selected cells.

I would like to get this macro changed to include also a specific fill
for a HEADER row (selected cells at the very top), ...
ie. the selected cells will also contain a header row. And these
header cells should get the following fill:
RGB(165, 165, 165), the font of this header is to be changed to bold
and font color is to be changed to white.
Help is much appreciated. Thank you very much in advance.
Regards, Andreas

Sub AltShade_GreyRed()
* * Dim Counter As Integer

* * If MsgBox("Would you like to apply an alternate shading to
selected cells (grey/red)?", vbQuestion + vbYesNo, "Selected cells
alternate shading grey/red") = vbNo Then
* * * * Exit Sub
* * * * End If

* * 'For every row in the current selection...
* * For Counter = 1 To Selection.Rows.Count
* * * * 'If the row is an odd number (within the selection)...
* * * * If Counter Mod 2 = 1 Then
* * * * * * 'Set the color to ...
* * * * * * Selection.Rows(Counter).Interior.Color = RGB(229, 229,
229)
* * * * * * 'If the row is an even number (within the selection)
* * * * * * *Else
* * * * * * Selection.Rows(Counter).Interior.Color = RGB(239, 211,
210)
* * * * End If
* * Next

End Sub


Hi Jim,

I was pretty sure that I already got back to you with a feedback.
Obviously not. Ok, now, thank you very much for your professional
support. Exactly what I wanted. Thank you very much. Regards, Andreas
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
Alternate Shading for non-bold rows andreashermle Excel Programming 2 March 25th 10 11:34 AM
How do I alternate shading of rows, Excel 2007, no new tabs. jrgspyder Excel Discussion (Misc queries) 1 June 11th 09 03:21 AM
Alternate Row Shading (Visible Rows Only) Forgone Excel Worksheet Functions 9 September 24th 08 06:26 AM
Color alternate rows when after hiding selected rows Monk[_2_] Excel Worksheet Functions 6 June 7th 08 01:36 AM
shading alternate rows, but losing format when one row is deleted Candice Excel Discussion (Misc queries) 8 May 11th 06 04:01 AM


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