![]() |
Using ShadeAlternate Subroutines as Macro
I located the exact tip I was looking for in ExcelTip for shadin
alternate rows. What I need to do is select the rows and columns want shaded and then call a macro to do the job. I found the tip a the following URL: http://www.exceltip.com/st/Row_and_c...Excel/488.html For me, the problem is that they are written as subroutines tha require arguments to operate. Can someone help me, first time usin VBA in Excel, to come up with a way to allow me to use the subroutin to shade the rows in the area that I highlight? Exceltip.com is a great resource. Not sure why I hadn't found i before! Thanks! Davi -- Message posted from http://www.ExcelForum.com |
Using ShadeAlternate Subroutines as Macro
David
the first one could be modified thus: Sub ShadeAlternateRowsModified() Dim rngTarget As Range, intColor As Integer, lngStep As Long ' adds a background color = intColor to every lngStep rows in rngTarget ' example: ShadeAlternateRows Range("A1:D50"), 27, 2 ' colors every 2 rows light yellow Dim r As Long Set rngTarget = Selection intColor = 27 lngStep = 2 If rngTarget Is Nothing Then Exit Sub With rngTarget .Interior.ColorIndex = xlColorIndexNone ' remove any previous shading For r = lngStep To .Rows.Count Step lngStep .Rows(r).Interior.ColorIndex = intColor Next r End With End Sub I'll leave the other to you. Regards Trevor "dbfoxnh " wrote in message ... I located the exact tip I was looking for in ExcelTip for shading alternate rows. What I need to do is select the rows and columns I want shaded and then call a macro to do the job. I found the tip at the following URL: http://www.exceltip.com/st/Row_and_c...ng_VBA_in_Micr osoft_Excel/488.html For me, the problem is that they are written as subroutines that require arguments to operate. Can someone help me, first time using VBA in Excel, to come up with a way to allow me to use the subroutine to shade the rows in the area that I highlight? Exceltip.com is a great resource. Not sure why I hadn't found it before! Thanks! David --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 07:33 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com