Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-22-2015, 10:44 PM
gmayor's Avatar
gmayor gmayor is offline 30+ emtpy page output Windows 7 64bit 30+ emtpy page output Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

This sort of thing occurs when there is phantom data in cells not used for the merge (maybe a space that is difficult to spot). The following Excel macro should enable you to clean up the worksheet to avoid the problem. Certainly it fixes the problem on the example sheet you provided.

Code:
Option Explicit

Sub CleanSheet()
Dim xlSheet As Object
Dim iCols As Long, iCol As Long, c As Long
Dim iRows As Long, iRow As Long, r As Long
    Set xlSheet = ActiveSheet
    iRows = xlSheet.UsedRange.Rows.Count
    iCols = xlSheet.UsedRange.Columns.Count
    iRow = xlSheet.Cells(xlSheet.Rows.Count, 1).End(-4162).Row
    iCol = xlSheet.Cells(1, xlSheet.Columns.Count).End(-4159).Column
    If iRows > iRow Then
        For r = iRows To iRow + 1 Step -1
            xlSheet.Rows(r).EntireRow.Delete
            DoEvents
        Next r
    End If
    If iCols > iCol Then
        For c = iCols To iCol + 1 Step -1
            xlSheet.Columns(c).EntireColumn.Delete
            DoEvents
        Next c
    End If
    Set xlSheet = Nothing
lbl_Exit:
    Exit Sub
End Sub

__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I output text to a specific cell (x,y)? norwood Word VBA 2 01-31-2014 08:43 AM
Fix data output position relative to page Al See Mail Merge 1 01-16-2014 04:13 PM
mail merge – output to .pdf eNGiNe Mail Merge 3 09-29-2013 11:45 PM
30+ emtpy page output Input from excel, output to word conradin Word 3 04-20-2011 07:48 PM
Output Presentation Settings yeapurvz10 PowerPoint 0 09-17-2010 10:30 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft