> > 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? > > That depends on when the highlighting should happen.
I'm most interested in learning how to do it manually (e.g., after manually selecting a range). > > 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? > > You have to make the code a public sub. Just put the keyword public in > front of sub. I did this and it's still not showing up. (What's odd is that other macros that just start with Sub - all located in Module 1 of the workbook - are listed.) I tried putting the code in three places: in an individual worksheet (under MS Excel Objects), in "ThisWorkbook" (under under MS Excel Objects), and in Module 1 (under Modules). The code is: Public Sub ShadeAlternateRows(rngTarget As Range, intColor As Integer, lngStep As Long) 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 > > 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.) > > You have to add the line > "ShadeAlternateRows Range("A1:D50"), 27, 2" > in the Workbook_open method, not the code of ShadeAlternateRows. > ShadeAlternateRows is best be placed in the code module that is called > ThisWorkbook (I'm not sure about the name since I use a different > locale). Ah! Very clear. So it's like calling a function. -- ---------------------------------------------------------------------------------- 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