Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Pat Pat is offline
external usenet poster
 
Posts: 122
Default Find last row of data and delete empty rows

I need a macro that will find the last row in colA containing data and then
delete the next 100 empty rows.
Thank you if you can help.
Pat


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Find last row of data and delete empty rows

Try this
Sub deletenext100()
lastrow = ActiveSheet.UsedRange.Rows.Count
Range(Cells(lastrow + 1, 1), Cells(lastrow + 100, 1)).Select
Selection.EntireRow.Delete
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find last row of data and delete empty rows

cells(rows.count,1).End(xlup) _
.offset(1,0).Resize(100).Entirerow.Delete

--
Regards,
Tom Ogilvy

"Pat" wrote in message
...
I need a macro that will find the last row in colA containing data and

then
delete the next 100 empty rows.
Thank you if you can help.
Pat




  #4   Report Post  
Posted to microsoft.public.excel.programming
Pat Pat is offline
external usenet poster
 
Posts: 122
Default Find last row of data and delete empty rows

Hi gentlemen,

Thank you for your help. Both suggestions has not been successful. Perhaps
it needs to be modified to reflect its use. The empty rows the code is
deleting is below where the copy/paste is being performed. The empty rows
are in fact within the copy/paste region and it is these rows which need to
be deleted.


Application.DisplayAlerts = False
Range("D8:J930").Select
Selection.Copy

ChDir _
"C:\Documents and Settings\All Users\Documents\My Documents\Excel
books 2005"
Workbooks.Open Filename:= _
"C:\Documents and Settings\All Users\Documents\My Documents\Excel
books 2005\PrepareForHLS.xls"
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Selection.Replace What:="0", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Application.CutCopyMode = False

' delete next 100 rows
LastRow = ActiveSheet.UsedRange.Rows.Count
Range(Cells(LastRow + 1, 1), Cells(LastRow + 100, 1)).Select
Selection.EntireRow.Delete

ChDir "C:\HLSexcel"
ActiveWorkbook.SaveAs Filename:="C:\HLSexcel\ReadyForHLS.csv",
FileFormat:= _
xlCSV, CreateBackup:=False
Application.DisplayAlerts = True
Windows("Management.xls").Activate

Range("D10").Select


Pat



"Chip" wrote in message
oups.com...
Try this
Sub deletenext100()
lastrow = ActiveSheet.UsedRange.Rows.Count
Range(Cells(lastrow + 1, 1), Cells(lastrow + 100, 1)).Select
Selection.EntireRow.Delete
End Sub



Reply
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
Hpw do I delete multiple empty rows found between filled rows? Bill Excel Worksheet Functions 2 November 15th 09 07:12 PM
delete rows with empty cells throughout the data rutski Excel Worksheet Functions 4 November 16th 07 04:24 PM
How to Delete empty rows in excel in b/w rows with values Dennis Excel Worksheet Functions 3 August 28th 07 04:15 PM
Cut filtered rows, paste into next empty row of new sheet, and delete cut rows Scott Excel Worksheet Functions 0 December 13th 06 01:25 AM
how do i find and delete all empty rows in an excel worksheet AinSF Excel Worksheet Functions 3 September 1st 06 01:38 AM


All times are GMT +1. The time now is 05:21 PM.

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

About Us

"It's about Microsoft Excel"