+ Reply to Thread
Results 1 to 4 of 4

Delete rows in sheet by looping backwards !

  1. #1
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Kiruna
    Posts
    163

    Delete rows in sheet by looping backwards !

    Hi

    I have imported a textfile to my sheet thats could looks like this

    textfile:
    aaaa 11111 25622
    bbbb 22222 254155
    cccc 33333 356998
    dddd 44444 532256


    aaaa 11111 522546
    bbbb 22222 154123
    cccc 33333 44512
    dddd 55555 11255
    (2)
    aaaa 11111 5245454
    bbbb 22245 556t565
    cccc 33333 4454545
    dddd 55555 4545454(1)

    Is it possible to loop from last row (1) to first empty row (2) and delete that row plus all the rows above
    so it looks like this ?

    textfile
    aaaa 11111 5245454
    bbbb 22245 556t565
    cccc 33333 4454545
    dddd 55555 4545454

    Best regards

    Petter

    Bok1.xlsx
    Last edited by Petter120; 05-10-2012 at 08:03 AM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,303

    Re: Delete rows in sheet by looping backwards !

    Hi Petter120,

    No loop needed. Try this code

    Please Login or Register  to view this content.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Delete rows in sheet by looping backwards !

    Hello Petter120,

    When writing code in VBA, it is seldom necessary to select or activate objects. This macro assumes there will be at least one blank row separating the data.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Contributor
    Join Date
    12-05-2008
    Location
    Kiruna
    Posts
    163

    Re: Delete rows in sheet by looping backwards !

    Oh wow that was really useful thank you both verry much

+ 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