Insert row VBA code

  • Thread starter Thread starter DDH
  • Start date Start date
D

DDH

Thank you for your help. I am trying to build and find code like below
that will insert a row in columns A to P. If I put my curser on A5 and
click on a macro button then it will insert a line on A6 from column A
to P. Or if I put the curser on A10 or A50 that it would do the same
thing. I have tried the code below and I know it is wrong for the
"Entire Row" is wrong. But I cannot make it work. Thank you for your
help.



Sub InsertRows()
Sheets("sheet1").Activate
Selection.EntireRow.Insert Shift:=xlDown
Sub yInsertA3P3CellsDown()
Range("A3:P3").Insert Shift:=xlDown
End Sub
 
One way:

Public Sub InsertRow()
Cells(ActiveCell.Row + 1, 1).Resize(1, 17).Insert _
Shift:=xlDown
End Sub
 
Thank you so very much for your help.
It works perfect. I wished I understood it as well as you do.
When I look at the code I think I understand what you done but when
try to do it on my own I just am not smart enough.
I have a very hard time when the cell locations are not hard wired i
and the locations must be random. You are very nice group of people.
Thank yo
 
Has little to do with smarts and much to do with using it on a daily
basis. Keep hanging around the newsgroups and you'll get there.
 
Back
Top