On 29 Jun., Kurt wrote:
> I would like to highlight every other row in a range (A5:L40).
> 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)
[snip]
> 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.
You provided the answer to this question yourself, see question three.
> 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.
> 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).
Regards,
Stuart
--
----------------------------------------------------------------------------------
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 [email protected]
<><><><><><><><><><><><><><><><><><><><><><>
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