PC Review


Reply
Thread Tools Rate Thread

Apply Alternate Shading to selected rows

 
 
andreashermle
Guest
Posts: n/a
 
      6th Oct 2010
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
 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      6th Oct 2010
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" <(E-Mail Removed)>
wrote in message
news:dcc52622-0db3-4a73-b9e3-(E-Mail Removed)...
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
 
Reply With Quote
 
andreashermle
Guest
Posts: n/a
 
      21st Oct 2010
On 6 Okt., 14:26, "Jim Cone" <james.cone...@comcast.netXXX> 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" <andreas.her...@gmx.de>
> wrote in messagenews:dcc52622-0db3-4a73-b9e3-(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alternate Shading for non-bold rows andreashermle Microsoft Excel Programming 1 25th Mar 2010 11:34 AM
Alternate Row Shading (Visible Rows Only) Forgone Microsoft Excel Worksheet Functions 9 24th Sep 2008 06:26 AM
Alternate Shading of Rows in a Form R Hinds Microsoft Access Forms 2 10th Aug 2004 08:51 PM
shading alternate rows ardell Microsoft Excel Worksheet Functions 1 28th Jul 2004 09:48 PM
Alternate shading of rows Dale Hymel Microsoft Excel Worksheet Functions 2 24th Dec 2003 03:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:44 PM.