Closed Thread
Results 1 to 8 of 8

How to delete the last unwanted rows

  1. #1
    Forum Contributor
    Join Date
    06-20-2012
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    359

    How to delete the last unwanted rows

    Hello,

    I have Sorted list of data with serial numbers. My task is to identify the last serial number which is 8 in the below and delete all the rows to the end after the last serial number. Can anyone look if it can be done using a VBA?


    S.NO
    1
    2
    3
    4
    5
    6
    7
    8
    BRANCH-NAME
    CONDITION IS DISPLAYED FOR
    CONDITION IS DISPLAYED FOR
    CUSTOMER-NAME
    CUSTOMER-NAME
    LIST
    LIST

    Regards,

    Zaska
    Last edited by zaska; 03-17-2013 at 07:35 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to delete the last unwanted rows

    Hi,

    You don't really need a macro, although you could of course encode the process below in a macro.

    Enter in B2 and copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then filter column B for the word 'Delete', select all the filtered rows and hit the delete key.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    06-20-2012
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    359

    Re: How to delete the last unwanted rows

    Sir,

    Thanks for the suggestion. Could you please tell me how to encode the same process into this macro. As i have to deal with many excel sheets iam looking for a vba.

    Please Login or Register  to view this content.
    Thank you

  4. #4
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: How to delete the last unwanted rows

    Hi zaska,

    Try below code:-
    Please Login or Register  to view this content.
    see attachment:- Delete rows after heading.xlsm


    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to delete the last unwanted rows

    Hi,

    Your macro does not appear to contain the same data as your example. For instance you refer to column C in your macro, but there is nothing in column C. Similarly there are no cells with '----' in them.

    If you are seeking answers here it's incumbent on you to let us have all relevant information.
    The sort of looping macro you have in mind is not the most efficient way. Can I suggest you manually try the process I gave you and if this works then let me know and I'll encode that in a macro for you. Otherwise provide an example of your real data which includes all possible conditions.

  6. #6
    Forum Contributor
    Join Date
    06-20-2012
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    359

    Re: How to delete the last unwanted rows

    Hello,

    I am herewith attaching the example file which includes the real data. I want to sort the data according to the serial number in column a and delete the rest of the unwanted rows after sorting.

    Thank you
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to delete the last unwanted rows

    Is this what you are after?
    Please Login or Register  to view this content.

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to delete the last unwanted rows

    It has come to my attention that this is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed.

    Thread Closed.

Closed 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