Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-19-2018, 12:45 PM
kevinbradley57 kevinbradley57 is offline Somehow getting extra blank rows with borders Windows 7 64bit Somehow getting extra blank rows with borders Office 2010 64bit
Advanced Beginner
Somehow getting extra blank rows with borders
 
Join Date: Jul 2017
Posts: 87
kevinbradley57 is on a distinguished road
Default

NoSparks - Thanks for the quick response, but neither of those instructions worked for me.
Reply With Quote
  #2  
Old 09-19-2018, 01:01 PM
kevinbradley57 kevinbradley57 is offline Somehow getting extra blank rows with borders Windows 7 64bit Somehow getting extra blank rows with borders Office 2010 64bit
Advanced Beginner
Somehow getting extra blank rows with borders
 
Join Date: Jul 2017
Posts: 87
kevinbradley57 is on a distinguished road
Default

NoSparks -- Your comment inspired me to look for (and find) code that resets the used range when data is copied from another source (that last bit is important). This works:
Code:
Sub Delete_Empty_Row()
    Application.ScreenUpdating = False
    For Each usedrng In ActiveSheet.UsedRange
        If usedrng.MergeCells = True Then
            If usedrng.Value = "" Then
                usedrng.Value = ""
            End If
        Else
            If usedrng.Value = "" Then
                usedrng.ClearContents
            End If
        End If
    Next
    
    ActiveSheet.UsedRange
    usedRangeLastColNum = ActiveSheet.UsedRange.Columns.Count
    usedrangelastrow = ActiveSheet.UsedRange.Rows.Count
    
    For r = usedrangelastrow To 1 Step -1
        If Application.WorksheetFunction.CountA(Cells(r, usedRangeLastColNum).EntireRow) <> 0 Then
            Exit For
        Else
            Cells(r, usedRangeLastColNum).EntireRow.Delete
        End If
    Next r
    
    For c = usedRangeLastColNum To 1 Step -1
        If Application.WorksheetFunction.CountA(Cells(1, c).EntireColumn) <> 0 Then
            Exit For
        Else
            Cells(1, c).EntireColumn.Delete
        End If
    Next c
    
    ActiveSheet.UsedRange
    Application.ScreenUpdating = True
End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Template with background colors has extra blank page that will not delete. jspinelli27 Word 1 03-11-2018 02:27 PM
Section Break Inserts an Extra Blank Page Nathan8752 Word 3 12-09-2015 07:03 AM
Somehow getting extra blank rows with borders Delete blank rows between the two rows that contain data beginner Excel Programming 5 12-26-2014 12:29 AM
Extra lines in directroy when field is blank redzan Mail Merge 5 05-23-2014 06:40 PM
Somehow getting extra blank rows with borders Count rows and add blank rows accordingly Hoochtheseal Word VBA 1 01-29-2013 09:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:52 PM.


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