LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Delete Blank Rows Code - Multiple Worksheets - Multiple Documents

I would tremendously appreciate help in coding a deletion of all blank rows
from all worksheets in all files within a certain directory.

I have code that merges multiple documents but I found that any blank row
will stop the merge at that point. The number of documents makes manual
deletion too costly in terms of time and effort.

I found the following code elsewhere for deleting blanks from a single
worksheet...can anyone tell me how to generalize this to multiple sheets &
multiple documents? Below I will include the code I have both for deleting
empty rows from a single sheet and for combining multiple sheets/documents.
I'll separate with a big ************************. Thanks!!!!

Sub DeleteEmptyRows()

Dim LastRow As Long, r As Long

LastRow = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False

For r = LastRow To 1 Step -1
If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r

Application.ScreenUpdating = True

End Sub
************************************************** ************************************************** ************************************************** ******************************
Sub ConsolidateWithLabels()
' Will consolidate Mulitple Sheets
' from Multiple Files onto one sheet
' Never tested with files that would
' give more than one sheets as end result
' Assumes that all data starts in cell A1 and
' is contiguous, with no blanks in column A

With Application
.DisplayAlerts = False
.EnableEvents = False
.ScreenUpdating = False
End With

With Application.FileSearch
.NewSearch
'Change this to your directory
.LookIn = ThisWorkbook.Path
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
Set Basebook = ThisWorkbook
For i = 1 To .FoundFiles.Count
If .FoundFiles(i) < ThisWorkbook.FullName Then
Set myBook = Workbooks.Open(.FoundFiles(i))
For Each mySheet In myBook.Worksheets
mySheet.Activate
Range("A1").CurrentRegion.Copy _
Basebook.Worksheets(1).Range("C65536").End(xlUp).O ffset(1, 0)
With Basebook.Worksheets(1)
.Range(.Range("A65536").End(xlUp).Offset(1, 0), _
.Range("C65536").End(xlUp).Offset(0, -2)).Value = _
myBook.Name
.Range(.Range("B65536").End(xlUp).Offset(1, 0), _
.Range("C65536").End(xlUp).Offset(0, -1)).Value = _
mySheet.Name
End With
Next mySheet
myBook.Close
End If
Next i
End If
End With

With Application
.DisplayAlerts = True
.EnableEvents = True
.ScreenUpdating = True
End With

Basebook.SaveAs Application.GetSaveAsFilename

End Sub


 
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
In Office 2000, How do I delete multiple blank rows at one time? gisieber Excel Worksheet Functions 2 May 16th 06 05:27 PM
insert or delete rows across multiple worksheets? BobW Excel Discussion (Misc queries) 1 February 16th 06 05:02 PM
Can I delete multiple blank rows collectively? bursar Excel Worksheet Functions 1 January 4th 06 12:10 PM
I want to delete multiple blank rows from a spreadsheet Sharon43 New Users to Excel 2 October 8th 05 12:44 AM
delete rows from multiple worksheets dckrause Excel Worksheet Functions 1 June 1st 05 03:24 AM


All times are GMT +1. The time now is 02:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"