View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Janet H[_2_] Janet H[_2_] is offline
external usenet poster
 
Posts: 16
Default Inserting rows at variable points

The macro below allows the user to insert 8 rows on a diary card type form
when needed, using the last blank row on the form. The macro is intended to
be run over and over, however, unless I make the references variable, the
rows will be inserted in the middle of data entry. I don't know how to make
the last row and the inserted rows always occur at the end of the entries. I
can't count the rows to determine the end because I have other entries in
rows below, representing the next page of the form.

Any help is appreciated.

Sub Insertrows1()

ActiveSheet.Unprotect
Range("A23").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Rows("45:45").Select<-------------------- I want this to be one up from
end down, end down, which will be last row of the form.

Selection.Copy
Rows("46:54").Select<---------------------- I want this to be 8 rows
after the last row
Selection.Insert Shift:=xlDown
Range("A46").Select
Selection.End(xlDown).Select
Range("A54").Select<---------- I want to return the user to the last
row, before the insertion of new rows.
ActiveSheet.Protect
End Sub