Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Inserting rows at variable points

How about doing End(xlup) instead.

Range("A65536").End(xlup).Offset(-1,0).Select

Selection.Resize(8).EntireRow.Insert

Range("A65536").End(xlup).Select

--
Regards,
Tom Ogilvy


"Janet H" wrote in message
...
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






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Inserting rows at variable points

That won't work because I have another form which represents the 2nd page of
the document.

End down, end down, 1 up will work because it will always put me at the last
row of form 1 (I think), even if they've previously inserted rows. My
instructions will tell them to to insert before they enter data on the last
row.

I need help with the "1 up"

Thanks.

"Tom Ogilvy" wrote:

How about doing End(xlup) instead.

Range("A65536").End(xlup).Offset(-1,0).Select

Selection.Resize(8).EntireRow.Insert

Range("A65536").End(xlup).Select

--
Regards,
Tom Ogilvy


"Janet H" wrote in message
...
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







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Inserting rows at variable points

Range("A65536").End(xlup).Offset(-1,0).Select

the offset(-1,0).Select is the one up part.

--
Regards,
Tom Ogilvy

"Janet H" wrote in message
...
That won't work because I have another form which represents the 2nd page

of
the document.

End down, end down, 1 up will work because it will always put me at the

last
row of form 1 (I think), even if they've previously inserted rows. My
instructions will tell them to to insert before they enter data on the

last
row.

I need help with the "1 up"

Thanks.

"Tom Ogilvy" wrote:

How about doing End(xlup) instead.

Range("A65536").End(xlup).Offset(-1,0).Select

Selection.Resize(8).EntireRow.Insert

Range("A65536").End(xlup).Select

--
Regards,
Tom Ogilvy


"Janet H" wrote in message
...
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









  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Inserting rows at variable points

That wasn't it. It takes me to the wrong section of the spreadsheet.

This is what I ended up doing -

Range("A23").Select
Selection.End(xlDown).Select
Selection.End(xlDown).EntireRow.Offset(-1, 0).Select
Selection.Copy
Selection.Resize(8).EntireRow.Insert
Selection.End(xlUp).Select


"Tom Ogilvy" wrote:

Range("A65536").End(xlup).Offset(-1,0).Select


the offset(-1,0).Select is the one up part.

--
Regards,
Tom Ogilvy

"Janet H" wrote in message
...
That won't work because I have another form which represents the 2nd page

of
the document.

End down, end down, 1 up will work because it will always put me at the

last
row of form 1 (I think), even if they've previously inserted rows. My
instructions will tell them to to insert before they enter data on the

last
row.

I need help with the "1 up"

Thanks.

"Tom Ogilvy" wrote:

How about doing End(xlup) instead.

Range("A65536").End(xlup).Offset(-1,0).Select

Selection.Resize(8).EntireRow.Insert

Range("A65536").End(xlup).Select

--
Regards,
Tom Ogilvy


"Janet H" wrote in message
...
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










Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
inserting specific points on a graph and label them? cj_69 Charts and Charting in Excel 5 December 13th 07 02:15 PM
Inserting Variable Number of Rows bundyloco[_7_] Excel Programming 2 August 29th 05 11:25 AM
variable cell referencing for simple data points pno1 Excel Programming 4 May 19th 05 03:54 PM
Inserting a variable number of rows in a worksheet kls[_2_] Excel Programming 1 August 20th 04 01:47 PM
inserting a variable into VB edb Excel Programming 2 February 29th 04 12:39 PM


All times are GMT +1. The time now is 11:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"