Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default This May Be A Challenge

Hola Robert el reto que me pusistes no estaba tan duro ahora tu reto es
traducir esto!!
A, por cierto Aqui esta tu Codigo, Saludos.

Sub InsertPageBreaks7()
Dim Counter As Long
Dim TotalCounter As Variant
Dim PageBreakscounter As Long
Dim LastRow As Variant
Dim i As Integer
0: Range("C1").Select
On Error Resume Next
For i = 1 To ActiveWindow.SelectedSheets.HPageBreaks.Count
ActiveWindow.SelectedSheets.HPageBreaks(i).Delete
Next i
LastRow = Range("C35200").End(xlUp).Row
If Cells(LastRow, 3) = "StopHere" Then
GoTo 10
Else
Cells(LastRow, 3).Offset(1, 0) = "StopHere"
End If

10: Do Until ActiveCell = "StopHere"
If Selection = "Total" Then
TotalCounter = TotalCounter + 1
If TotalCounter = 7 Then
ActiveWindow.SelectedSheets.HPageBreaks.Add
Befo=ActiveCell.Offset(1, 0)
PageBreakscounter = 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

Jose Rojas
MMNUS
"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




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
Who's up for a Challenge? Growe1 Excel Worksheet Functions 4 March 16th 09 05:33 AM
Challenge for Anyone to take it on. SO CONFUSED Excel Worksheet Functions 4 November 12th 08 10:42 AM
A challenge doss04 New Users to Excel 0 October 22nd 08 08:03 AM
Challenge OwenGiryluk Excel Worksheet Functions 10 October 1st 07 10:33 PM
A Challenge jimbob Excel Discussion (Misc queries) 17 April 1st 06 10:37 PM


All times are GMT +1. The time now is 01:05 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"