VBA code to add rows

F

FSt1

hi,
To add a row to the sheet.....
Rows("6:6").Select
Selection.Insert Shift:=xlDown

To add a row to a range.........
Range("A6:I6").Select
Selection.Insert Shift:=xlDown

FSt1
 
K

Kiran

Hi FST1,
thanks for replying. But I does not solve, what this code is doing is moving
the data from the selected row. I dont want to move data. When I click the
Get me a New Row button, I want to generate a new row.
So basically automating
Right-click -> Insert Row below the selected cell.

Hope i was clearer this time
 
F

FSt1

hi,
the code is adding a row. it has to "move" the data to add the row.
If you want the row added below certain data, then select the cell below the
data then run the code.
example:
You have data on row 6 and wish to add a row below it.
Click anywhere on row 7

Selection.entirerow.Insert Shift:=xlDown

FSt1
 
P

PegL

Now I'm not sure what you're really trying to do. The code FST1 provided
inserts a row above row 6. You'd obviously modify it to insert where you
want it. If you want to insert after a certain location, simply reference
the cell below it. Technically, you can't add a row in Excel. It has 65536
rows, period.
 
Top