+ Reply to Thread
Results 1 to 3 of 3

XlUp 55 rows and delete

Hybrid View

  1. #1
    Registered User
    Join Date
    10-12-2010
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    9

    XlUp 55 rows and delete

    I'm looking to choose column B, move down to the last row of data and then delete everything in the last 55 rows from Column B over (A remains stagnant). Right now this is erroring out for me and there may be a much simpler way to do what I'm trying to do. Any help is appreciated.

    Range("B2").Select
        Selection.End(xlDown).Select
        ActiveWindow.SmallScroll Down:=-31
        Dim n As Long
        n = 55
        Cells(Rows.Count, "B").End(XlUp.Offset(1-n).
        ActiveCell.Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.ClearContents
    End Sub
    Last edited by Chad Kruse; 10-19-2010 at 01:26 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: XlUp 55 rows and delete

    One way:
        Const nRow As Long = 55
    
        On Error Resume Next
        Cells(Rows.Count, "B").End(xlUp).Offset(1 - nRow).Resize(nRow, Columns.Count - 1).ClearContents
    The OERN statement avoids a runtime error if there are less than 55 rows available to clear.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    10-12-2010
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: XlUp 55 rows and delete

    shg,

    Thank you that works perfectly. The logic of mine was a bit off. Glad I found this forum to correct my errors.

    Thanks again.

+ 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