Advertisement

01.23.2008 at 11:41AM PST, ID: 23105574
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Print set of rows together

Tags: Microsoft, Excel, 2003
Is there a way to keep some contiguous rows together while printing in Excel? We want to keep the rows in such a way that either all of those print to current page or all of those print to next page i.e. the page break should not separate those rows. We already have overall PrintArea setup to fit the columns in one page width and let Excel decide the page breaks.
Start your free trial to view this solution
Question Stats
Zone: Software
Question Asked By: amit_g
Solution Provided By: byundt
Participating Experts: 3
Solution Grade: A
Views: 14
Translate:
Loading Advertisement...
01.23.2008 at 03:07PM PST, ID: 20728904

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.23.2008 at 03:16PM PST, ID: 20728980

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.23.2008 at 03:19PM PST, ID: 20729010

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.23.2008 at 03:20PM PST, ID: 20729019

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.23.2008 at 06:46PM PST, ID: 20730168

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.23.2008 at 07:05PM PST, ID: 20730238

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.23.2008 at 08:50PM PST, ID: 20730714

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.24.2008 at 10:50AM PST, ID: 20736005

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.24.2008 at 12:51PM PST, ID: 20737267

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
01.23.2008 at 03:07PM PST, ID: 20728904
Why not just use the page break view and set the breaks where you want them??
Goto VIEW -> PAGE BREAK PREVIEW
 
01.23.2008 at 03:16PM PST, ID: 20728980

Rank: Guru

Would View>Page break review be any good for you?
It allows you to adjust the page breaks manually.

Regards,
Curt
 
01.23.2008 at 03:19PM PST, ID: 20729010

Rank: Guru

I'm too slow, beaten by 9 minutes! But may amit_g is after something automatic anyway?

Curt
 
01.23.2008 at 03:20PM PST, ID: 20729019
>>Why not just use the page break view and set the breaks where you want them??

Because I have to do it programatically and I don't know in advance how many rows would each group consist of.
 
01.23.2008 at 06:46PM PST, ID: 20730168

Rank: Guru

Couldn't you always add a page break before the group of rows with
ActiveSheet.HPageBreaks.Add Before:=ActiveCell
That way the group of rows will always start on a new page even if it will sometimes leave a gap on the previous page.

Regards,
Curt
 
01.23.2008 at 07:05PM PST, ID: 20730238
No, because usually 3 or 4 such groups fit into one page. If I do so, only one group would print into each page and even thought there would be enough space for at least 2 if not 3 more groups.
 
01.23.2008 at 08:50PM PST, ID: 20730714

Rank: Guru

If you haven't got any case where there are less 3 groups maybe you could add the break after every third group?
 
01.24.2008 at 10:50AM PST, ID: 20736005
If it were so easy I would not be asking this here :) I am not a novice and I have also done a through "Googling". When I could not find anything satisfactorily, I have posted it here.

The groups are not static. In fact the report itself is not static, it is generated dynamically and numbers of rows within the group vary. Currently we are doing it a very hard way by counting the number of rows, then deciding if the page break should be put after a group based on how many groups can be fit in a page. That is very cumbersome and error prone and is to be done per report/per group. What I am looking for is to be able to mark some rows as a group in Excel so that it doesn't break it. If there is a way in Excel, we can use Excel automation to do that "marking" from the report generation engine and then we don't have to count the rows in each page per report.
 
01.24.2008 at 12:51PM PST, ID: 20737267

Rank: Genius

Amit,
You would think that Excel would make what you are trying to do easy--but it most certainly does not.

In my day job, I produce a routine document that contains a mix of rows with and without vertically merged cells. When Excel determines where the page breaks lie, it looks pretty dumb to have a vertically merged cell print partially on one page and the rest on another. It also looks dumb if an automatic page break puts a section header at the bottom of one page, with the content beginning on the next. I therefore wrote a routine to insert page breaks where they would look better. This routine is called by a Workbook_BeforePrint event sub.

I am posting the code below as an example only. It was written with the peculiarities of one specific workbook and its formatting in mind, and very likely needs modification to suit your circumstances.

Brad
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
Sub PrettyPageBreaks()
'Sets page breaks to avoid putting the green section header at bottom of page or splitting merged cells
Dim i As Long, j As Long, n As Long, scrollRow As Long, scrollColumn As Long
Dim cel As Range, LastCell As Range, rg As Range, rg1 As Range, rgPrintArea As Range
'On Error GoTo 0
Application.EnableEvents = False
Application.ScreenUpdating = False
With ActiveSheet
    Set rg1 = ActiveCell
    scrollRow = ActiveWindow.scrollRow
    scrollColumn = ActiveWindow.scrollColumn
    Set rgPrintArea = Intersect(.Range(.PageSetup.PrintArea), .UsedRange)
    
    .ResetAllPageBreaks             'Remove all existing page breaks, Zoom & "Fit to" settings
    .PageSetup.Zoom = False         'Must turn Zoom off and restore the "Fit to" settings
    .PageSetup.FitToPagesWide = 1
    .PageSetup.FitToPagesTall = 99
    ActiveWindow.View = xlPageBreakPreview
    
        'Put manual page breaks back in where needed to avoid "breaking" two merged rows
    .DisplayAutomaticPageBreaks = True      'This statement needed to reset count of page breaks
        'Bug in Excel 97-2003 means that automatic page breaks can be found reliably only if the active cell _
            is at the end of the print area and screen updating is "on". This next statement finds that cell _
            See http://support.microsoft.com/kb/210663/en-us
    Set LastCell = rgPrintArea.Find(What:="*", After:=rgPrintArea.Cells(1, 1), LookIn:=xlValues, _
                LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Offset(1, 0)
    LastCell.Select
    
    If .HPageBreaks.Count > 0 Then
        Application.ScreenUpdating = False
        Do
            i = i + 1
            .HPageBreaks(i).Location.EntireRow.Select   'Selection expands to include rows of any merged cells
            j = Selection.Row
            If .Cells(j - 1, 1).Interior.ColorIndex = 35 Then     'Don't end page on green row
                .Cells(j - 1, 1).EntireRow.Select
                j = Selection.Row
                If .Cells(j - 1, 1).Interior.ColorIndex = 35 Then
                    .Cells(j - 1, 1).EntireRow.Select
                    j = Selection.Row
                End If
            End If
            LastCell.Select
            If j <> .HPageBreaks(i).Location.Row Then
                Set .HPageBreaks(i).Location = .Cells(j, 1)     'This syntax is not suggested by on-line help!
             End If
            If i >= .HPageBreaks.Count Then Exit Do
        Loop
    End If
    
    rg1.Select    'Return to the original starting point
    ActiveWindow.scrollRow = scrollRow
    ActiveWindow.scrollColumn = scrollColumn
    ActiveWindow.View = xlNormalView
    Application.ScreenUpdating = True
    
End With
Application.EnableEvents = True
'On Error GoTo 0
End Sub
Open in New Window
Accepted Solution
 
 
02.04.2008 at 01:25PM PST, ID: 20818177
Amit,
Thanks for the kind words and grade! It's people like you who make this site worthwhile for the experts.

Assuming that you want to use my code as a starting point, but have problems with implementation, please continue posting in this thread. Doing so will make it more valuable in the Experts-Exchange database.

Brad
 
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628