Insert A Row

M

Mark Williams

Hi All,

I am trying to write a macro that will insert a row above a blank row in a
range I've named "PriorPTI". The blank row is the last row in a range that
contains 12 rows. The range will grow as I insert more rows. I am not a
programmer so any help will be greatly appreciated as I've spent two work
days trying to figure this out (Yes: it is rocket science :)).

Regards,
Mark
 
G

Gary Keramidas

this might be all you need.

Option Explicit

Dim lastrow As Long

Sub insertrow()
lastrow = Cells(Rows.Count, "A").End(xlUp).offset(1,0).Row
Range("a" & lastrow).EntireRow.Insert


End Sub
 
T

Tom Ogilvy

Dim rng as Range
set rng = Range("PriorPTT")
set rng = rng.rows(rng.rows.count)
rng.EntireRow.Insert
 
M

Mark Williams

Tom/Gary Thanks for your responses. Tom I copied your macro right into vis.
basic and received the following run time error: 1004 Method 'Range' of
object'_Global' failed. I did add Sub insertrow() before the macro and End
Sub at the end.

Thanks for your help.
Regards,
Mark
 
M

Mark Williams

Tom, Please ignore my previous post. The error was due to incorrect
spelling. Thanks for your help.

Gary, Thank you as well for your time. Its greatly appreciated.

Regards,
Mark
 

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