+ Reply to Thread
Results 1 to 9 of 9

Delete entire row when cell says delete

  1. #1
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Delete entire row when cell says delete

    Hi folks,

    i need some code that delete the entire row when a cell says deletein it:

    here's what i have so far:

    Please Login or Register  to view this content.
    i'm not sure why its not working but im sure you'll tell me why?

    cheers for reading my thread!
    Mr MaGoo
    Magoo.Inc MMVII

    If i've helped please add to my Rep by Clicking on the Blue Scales in the top right hand corner of the post

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,607
    At the moment your code loops until the active cell value is not 'Delete', then exits the loop, and since the If condition is not met does nothing.

    Are there multiple rows to be deleted? AutoFilter is a far better way to do this than looping, e.g.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    If the first cell isn't delete then the loop will stop

    See link for how to use loops

    http://www.exceltip.com/st/Using_Loo...Excel/628.html

    I would try

    Please Login or Register  to view this content.
    HTH

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Exclamation answer

    yeah there are lots of rows that need deleting, the reason my code says the above is because i have sorted the data so that the "delete" are all at the top.

    Here is my entire code for you to see,

    i changed it at the bottom so that the If criteria is inside the loop, although its not working, please feel free to modify this code to increase the speed and make it easier.

    Please Login or Register  to view this content.

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,607
    I've used AutoFilter. The code below assumes you have a header row starting in A1 and your block of data is contiguous, ie no completely blank rows in it.
    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Cheers

    Cheers for the help but that didn't work, it deleted all of the data!!

    not to worry i will do it maunally.

    unless you know how to select all the rows when a cell in column E has Delete in in?

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,607
    That's what it should do. Can you attach a sample workbook?

  8. #8
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808
    I can't buddy,

    its way too big to even zipp down not to worry ill crack it using trial and error!!

    thanks anyway buddy!!

  9. #9
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,607
    Just a sample of a few rows would do, but perhaps you have a masochistic streak ...

+ 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