+ Reply to Thread
Results 1 to 4 of 4

Find last row of data and delete empty rows

  1. #1
    Pat
    Guest

    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. #2
    Chip
    Guest

    Re: 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. #3
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:%[email protected]...
    > 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. #4
    Pat
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1