Office & Productivity Software forum

General discussion

A Useful MS Excel Macro

by PDRat / April 5, 2005 12:42 PM PDT

I use Excel (2002 - SP3) to maintain the membership list of a 650-member organization. When I have to edit the entries, to avoid making changes on the wrong line, I set the background color of the current row of interest to yellow. Moving on to the next line means erasing the yellow on the current line and yellowing the next line -- kind of clunky. So I wrote a macro to capture these actions, but it didn't work properly. Here's why: Let R be the number of the yellowed row, and let N = R+1. The macro embedded these two numbers literally, and was thus useless for moving on beyond these two rows. I found a way to fix the macro so it would work properly. I have pasted it in below, showing the lines that had to be added and modified.

Sub RoMark()
'
' RoMark Macro
' Macro recorded 4/5/2005 by PDRat
'
' Keyboard Shortcut: Ctrl+Shift+Y
'
Dim Row As Integer, Nxt As Integer 'Added by PDRat

Row = Selection.Row 'Added by PDRat
Nxt = Row + 1 'Added by PDRat

Selection.Copy
' Rows("8:8").Select 'Original
Rows(Nxt).Select 'Modified by PDRat
Selection.PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
' Rows("7:7").Select 'Original
Rows(Row).Select 'Modified by PDRat
Selection.Interior.ColorIndex = xlNone
End Sub

Discussion is locked
You are posting a reply to: A Useful MS Excel Macro
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: A Useful MS Excel Macro
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Popular Forums
icon
Computer Newbies 10,686 discussions
icon
Computer Help 54,365 discussions
icon
Laptops 21,181 discussions
icon
Networking & Wireless 16,313 discussions
icon
Phones 17,137 discussions
icon
Security 31,287 discussions
icon
TVs & Home Theaters 22,101 discussions
icon
Windows 7 8,164 discussions
icon
Windows 10 2,657 discussions

FALL TV PREMIERES

Your favorite shows are back!

Don’t miss your dramas, sitcoms and reality shows. Find out when and where they’re airing!