user's position of cursor influences macro

G

Guest

Novice macro user needs help. I have a spreadsheet in which I want my user
to intitiate a macro that inserts or deletes rows based on where she
positions the cursor. So, say the user wishes to insert a line above b12.
She positions the cursor on b12 and calls for the macro. How do I program
the macro to accept the user's positioning of the cursor to insert the rows
above the cursor's position? Thanks for sharing your knowledge.
 
G

Guest

Very cool. Thanks. But can I bother you for your assistance with a further
refinement? I'd also like to select the row below, copy and insert the
selection, and then clear the contents in the original rows of the second and
subsequent columns (leaving a formula undisturbed in column A). Is it
possible?
 
T

Tom Ogilvy

Sub abc()
ActiveCell.EntireRow.Insert
ActiveCell.EntireRow.Offset(1, 0).Copy ActiveCell.EntireRow
Cells(ActiveCell.Row + 1, 2).Resize(1, 255).ClearContents

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top