Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Inserting a row

Good day everyone,

On an excel spreadsheet, I'd like to insert a row every 16 rows. Then I'd
like to insert a copy of the first row and then again an empty row adding a
footer saying Page X of X....

Would someone know how I could write this in VBA ?

Thanks for your time

Denys
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Inserting a row

Sub BB()
Dim i As Long, j As Long
i = 1
j = 1
Do While Not IsEmpty(Cells(i, 1))
i = i + 1
j = j + 1
If j = 17 Then
Rows(i).Insert
j = 1
i = i + 1
End If
Loop
End Sub

inserts the rows. Change i to reflect the first row in the data that you
want separated into rows of 15. For example, if you have

row1 Header
row2
row3 1
.. . .
row18 16

then you would set i to 3

I don't know what you mean by insert a copy of the first row and an empty
row.

The footer is confusing as well. Sounds like you are missing Excel's built
in capabilities If you want to print sections of 16 rows, then put in
pagebreaks instead of rows. Use the rows to repeat at top in the 3rd tab of
page setup to indicate your header row and the blank row.
Then you can use a standard custom footer. (View=Header and Footer)

Sub BBB()
Dim i As Long, j As Long
i = 3
j = 1
Do While Not IsEmpty(Cells(i, 1))
i = i + 1
j = j + 1
If j = 17 Then
ActiveSheet.HPageBreaks.Add Befo=Rows(i)
j = 1
End If
Loop
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$2"
.CenterFooter = "Page &P of &N Pages"
End With
End Sub

--
Regards,
Tom Ogilvy



"Denys" wrote in message
...
Good day everyone,

On an excel spreadsheet, I'd like to insert a row every 16 rows. Then I'd
like to insert a copy of the first row and then again an empty row adding

a
footer saying Page X of X....

Would someone know how I could write this in VBA ?

Thanks for your time

Denys



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default Inserting a row

Or perhaps the builtin in capabilities of Freezing the first row for
display and of repeating the first row during printing.
http://www.mvps.org/dmcritchie/excel/freeze.htm
look at topic #freeze and at topic #printing
Tom did mention the printing so the freeze part for display
is what was still missing.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Tom Ogilvy" wrote in message ...
The footer is confusing as well. Sounds like you are missing Excel's built
in capabilities If you want to print sections of 16 rows, then put in
pagebreaks instead of rows. Use the rows to repeat at top in the 3rd tab of
page setup to indicate your header row and the blank row.
Then you can use a standard custom footer. (View=Header and Footer)



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Inserting a row

Hi Tom.

Thank you very much...This is going to be extremely helpful..

Have a nice weekend

Denys

"Tom Ogilvy" wrote:

Sub BB()
Dim i As Long, j As Long
i = 1
j = 1
Do While Not IsEmpty(Cells(i, 1))
i = i + 1
j = j + 1
If j = 17 Then
Rows(i).Insert
j = 1
i = i + 1
End If
Loop
End Sub

inserts the rows. Change i to reflect the first row in the data that you
want separated into rows of 15. For example, if you have

row1 Header
row2
row3 1
.. . .
row18 16

then you would set i to 3

I don't know what you mean by insert a copy of the first row and an empty
row.

The footer is confusing as well. Sounds like you are missing Excel's built
in capabilities If you want to print sections of 16 rows, then put in
pagebreaks instead of rows. Use the rows to repeat at top in the 3rd tab of
page setup to indicate your header row and the blank row.
Then you can use a standard custom footer. (View=Header and Footer)

Sub BBB()
Dim i As Long, j As Long
i = 3
j = 1
Do While Not IsEmpty(Cells(i, 1))
i = i + 1
j = j + 1
If j = 17 Then
ActiveSheet.HPageBreaks.Add Befo=Rows(i)
j = 1
End If
Loop
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$2"
.CenterFooter = "Page &P of &N Pages"
End With
End Sub

--
Regards,
Tom Ogilvy



"Denys" wrote in message
...
Good day everyone,

On an excel spreadsheet, I'd like to insert a row every 16 rows. Then I'd
like to insert a copy of the first row and then again an empty row adding

a
footer saying Page X of X....

Would someone know how I could write this in VBA ?

Thanks for your time

Denys




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 a row Pootle Excel Discussion (Misc queries) 7 February 24th 09 04:41 PM
Inserting new row Sure Excel Worksheet Functions 2 September 20th 08 02:35 AM
inserting zero dfg Excel Worksheet Functions 1 May 22nd 06 12:28 PM
inserting a row bforster1[_12_] Excel Programming 1 September 12th 04 04:57 AM
Inserting a row Lee Excel Programming 1 February 19th 04 08:10 PM


All times are GMT +1. The time now is 06:26 AM.

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

About Us

"It's about Microsoft Excel"