![]() |
This May Be A Challenge
Can you give more information about what did not work. I ran the macro on
my computer and it worked fine Paul D "Robert Gillard" wrote in message ... I recently posted the following problem, to which I received the reply below. Regrettably it does not work ... does anybody have any other suggestions. I receive a spreadsheet that has to have 14 page breaks (across the page only) inserted. The data varies in length each month ( by about 10 - 20 rows) and the page breaks need to be between "sections" The good news is that in column C (along with other text) there is the word "Total" in a cell on its own and this relates to each section. So ideally I want a macro that will count down 7 "Totals" and put a page break underneath this row, then count down another 7 "Totals" all down the spreadsheet which will result in 14 page breaks in all. Is this do-able and if so am I asking the right news group or should I be in Programming or macros. Bob ---------- Robert, Programming is probably the most appropriate group, but what the heck. Here's a little routine that may do it. Sub InsertPageBreaks7() Dim Counter As Long Range("C1").Select Do If Selection = "Total" Then TotalCounter = TotalCounter + 1 If TotalCounter = 7 Then ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell.Offset(1, 0) PageBreakscounter = PageBreakscounter + 1 If PageBreakscounter = 14 Then Exit Sub TotalCounter = 0 End If End If Selection.Offset(1, 0).Select ' move down Loop End Sub End Sub |
This May Be A Challenge
A couple things some of your variables were not declare then I add
"Paul D" wrote in message ... Can you give more information about what did not work. I ran the macro on my computer and it worked fine Paul D "Robert Gillard" wrote in message ... I recently posted the following problem, to which I received the reply below. Regrettably it does not work ... does anybody have any other suggestions. I receive a spreadsheet that has to have 14 page breaks (across the page only) inserted. The data varies in length each month ( by about 10 - 20 rows) and the page breaks need to be between "sections" The good news is that in column C (along with other text) there is the word "Total" in a cell on its own and this relates to each section. So ideally I want a macro that will count down 7 "Totals" and put a page break underneath this row, then count down another 7 "Totals" all down the spreadsheet which will result in 14 page breaks in all. Is this do-able and if so am I asking the right news group or should I be in Programming or macros. Bob ---------- Robert, Programming is probably the most appropriate group, but what the heck. Here's a little routine that may do it. Sub InsertPageBreaks7() Dim Counter As Long Range("C1").Select Do If Selection = "Total" Then TotalCounter = TotalCounter + 1 If TotalCounter = 7 Then ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell.Offset(1, 0) PageBreakscounter = PageBreakscounter + 1 If PageBreakscounter = 14 Then Exit Sub TotalCounter = 0 End If End If Selection.Offset(1, 0).Select ' move down Loop End Sub End Sub |
All times are GMT +1. The time now is 07:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com