ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MACRO - INSERT ROW (https://www.excelbanter.com/excel-programming/417605-macro-insert-row.html)

Chantelle

MACRO - INSERT ROW
 
Hi All,
I would like to create a macro with a box that allows the user to insert a
row by pressing the button. I have done this once before but many years ago
and I had a training book! Can someone help me? I know it is fairly simple
but I rarely use macros and I am not sure how to write the code.
Thanks
Chantelle

[email protected]

MACRO - INSERT ROW
 
On Sep 24, 9:28*pm, Chantelle
wrote:
Hi All,
I would like to create a macro with a box that allows the user to insert a
row by pressing the button. *I have done this once before but many years ago
and I had a training book! Can someone help me? I know it is fairly simple
but I rarely use macros and I am not sure how to write the code.
Thanks
Chantelle


Hi Chantelle,

This should do it for you. Attach it to a button or set it to a hotkey
under the macro options.

Steven

Sub InsRw()
Dim Rng as Range

Set Rng = ActiveCell.EntireRow

Rng.Insert Shift:=xlDown
Set Rng = Rng.Offset(1,0)
Rng.Select

End Sub

Bob Bridges[_2_]

MACRO - INSERT ROW
 
As a general rule of thumb, Chantelle, try this: Start recording a macro.
(Don't worry about the name and the comments, just rush on by that because
you won't be using them afterward.) Do the task you're trying to program.
Then stop recording the macro and go look at what was recorded in the macro.
You can almost always use what you see there, usually with some modification
but nothing very complicated.

Anything you don't understand in the macro, post a question here and ask
about THAT. You'll probably end up understanding more that way, and able to
do more for yourself and more quickly as a result.

--- "Chantelle" wrote:
I would like to create a macro with a box that allows the user to insert a
row by pressing the button. I have done this once before but many years ago
and I had a training book! Can someone help me? I know it is fairly simple
but I rarely use macros and I am not sure how to write the code.



All times are GMT +1. The time now is 07:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com