+ Reply to Thread
Results 1 to 5 of 5

macro to delete last two rows

  1. #1
    Forum Contributor
    Join Date
    09-29-2008
    Location
    usa
    MS-Off Ver
    EXCEL 2010
    Posts
    116

    macro to delete last two rows

    i wrote this macro and want to delete last two rows on active sheet this macro doesnt work can anybody help me please!!


    Sub deleteLast2Rows()
    With ThisWorkbook.Worksheets(1)
    Dim rowNum As Integer
    Dim m As Range


    rowNum = 2
    Set m = .Range("A" & rowNum)
    rowNum = rowNum - 2

    EntireRow.Delete
    End With
    End Sub
    Last edited by martinez_pedro; 03-26-2009 at 03:21 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: macro to delete last two rows

    Maybe this:
    Please Login or Register  to view this content.
    You should go back to your original post, GO ADVANCED, highlight the "code" section of your post and click on the # icon to wrap [code] tags around it, it's a forum rule.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    09-29-2008
    Location
    usa
    MS-Off Ver
    EXCEL 2010
    Posts
    116

    Re: macro to delete last two rows

    your are the best every reply that you do is always been rigth thankyou JBeaucaire

  4. #4
    Forum Contributor
    Join Date
    08-04-2010
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    110

    Re: macro to delete last two rows

    I may need to add this macro code to an existing macro of mine to remove lines from data.

    What do I need to change to be able to copy and paste it into my macro as I tried just slotting it into my code but unfortunately it failed to work.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: macro to delete last two rows

    Put the macro in a module of its own. Then in the other macro, CALL the macro when you need it.
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 03-23-2011 at 08:36 AM.

+ 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