Inserting & deleting a row

  • Thread starter Thread starter Chance
  • Start date Start date
C

Chance

Can someone help me write a macro that would insert a row
of cells above the selected ones on the worksheet? Also
one that would delete a selected row of cells.

Thanks,
Chance
 
Try this Change

For the activecell

Sub test()
ActiveCell.EntireRow.Insert
End Sub

Sub test2()
ActiveCell.EntireRow.Delete
End Sub


For the selcetion

Sub test()
Selection.EntireRow.Insert
End Sub

Sub test2()
Selection.EntireRow.Delete
End Sub
 
Assumes the activecell is top of selected range, will insert a row above that
activecell row.

If selecting from bottom up...

Sub insert_above_selection()
Set rng = Selection
Set rng1 = rng.Offset(0, rng.Columns.Count).Resize(1, 1)
rng1.Activate
rng1.EntireRow.Insert
End Sub

Gord Dibben Excel MVP
 
Much easier. Why do I always find a hard way?

Maybe because I already had the code to copy and paste?

Gord
 
Back
Top