I'm rather new to Excel macros so any help is appreciated. I would like to highlight every other row in a range (A5:L40). I do not want to use conditional formatting, because I'm already using some in this range. So, I need to use a macro.
I've seen lots of macro samples to shade alternate rows, but can't get any to work. For example, I found this one: Sub ShadeAlternateRows(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 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 1. The comment in this code has as an example, "ShadeAlternateRows Range("A1:D50"), 27, 2", but where in the actual code do you put this information? 2. When I put this code in the VB of my worksheet, it is not listed among the macros when I go to Tools > Macro > Macros. Any idea why? 3. If I want to run this macro, for example, on Worksheet "ABC" every time the workbook is open, I understand I need to put the code in the Workbook_Open module (between Private Sub Workbook_Open() & End Sub). If I do that, how do I modify the code (which already has a Sub and End Sub line.) Thank you for any clarification. -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 7000 subscribers worldwide and receive many nice notes about the learning and support from the group.Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe