Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Alternate Shading for non-bold rows | Excel Programming | |||
How do I alternate shading of rows, Excel 2007, no new tabs. | Excel Discussion (Misc queries) | |||
Alternate Row Shading (Visible Rows Only) | Excel Worksheet Functions | |||
Color alternate rows when after hiding selected rows | Excel Worksheet Functions | |||
shading alternate rows, but losing format when one row is deleted | Excel Discussion (Misc queries) |