View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Error when deleting rows

Hi W,

Try replacing:

ActiveSheet.Range("C8:C" &
lrow).SpecialCells(xlCellTypeBlanks).EntireRow.Del ete


with

On Error Resume Next
ActiveSheet.Range("C8:C" & LRow). _
SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0

Incidentally, although you have commnted the line:

'mybook.DisplayAlerts = False


If used, it should read:

Application.DisplayAlerts = False



---
Regards,
Norman


"wmureports" wrote in message
ps.com...
What i do is, I merge about 100 xls files into one master xls file.
But some records have empty rows that have to be deleted or they mess
up the formating. So i wrote some code but theres an issue. Heres a
part of the code:


Set mybook = Workbooks.Open(FNames)
'mybook.DisplayAlerts = False
lrow = LastRow(mybook.Sheets(1))
ActiveSheet.Range("C8:C" &
lrow).SpecialCells(xlCellTypeBlanks).EntireRow.Del ete
Set sourceRange = mybook.Worksheets(1).Range("A1:IV" &
lrow)
rnum = 1
SourceRcount = sourceRange.Rows.Count
Set destrange = basebook.Worksheets(1).Cells(rnum, "A")

sourceRange.Copy destrange

This does the job, it deletes the rows... BUT, when it comes to an XLS
file without any empty/blank rows, it generates an Error and stops
working. How would i make it do a check to see if theres actually
blank rows to begin with???

thanks in advance