+ Reply to Thread
Results 1 to 4 of 4

If...and...then row delete

  1. #1
    Registered User
    Join Date
    11-24-2012
    Location
    Hamburg, Germany
    MS-Off Ver
    Excel 2010
    Posts
    12

    If...and...then row delete

    Hello there!

    What I want the code to do is quite simple: Go through each cell of a column and delete every row that is not equal to two variables. It should start at row 2 and stop at the first emtpy cell.

    Now I have actually found an alternative to my code that works somewhere else but I would still like to know why mine won't work. It does work perfectly if I'm not using the "<>" operator but not using it isn't practical for my purposes. At the moment what it does is, it's deleting every 2nd row disregarding the content in the specified cell/column.
    So here's the code:

    Please Login or Register  to view this content.
    Thank you very much =)

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: If...and...then row delete

    If you delete a row then you musn't increment the index

    Do this instead:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    11-24-2012
    Location
    Hamburg, Germany
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: If...and...then row delete

    Aww, great, debugging for the win :D Should've thought of that myself...anyways, thank you very much for your time and knowledge!

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: If...and...then row delete

    You're welcome!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to delete certain columns and delete rows based on time in another column
    By beepbeep27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2012, 11:47 AM
  2. How to Delete a Range in Closed Workbook (to Replace Delete Query)
    By resant_v@yahoo.com in forum Excel General
    Replies: 1
    Last Post: 03-08-2006, 06:10 AM
  3. [SOLVED] Macro to delete sheets and saves remaining file does not properly delete module
    By pherrero in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2005, 08:12 PM
  4. Replies: 0
    Last Post: 06-21-2005, 01:05 PM
  5. [SOLVED] Re: Macro to delete sheets and saves remaining file does not properly delete module
    By pherrero in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-21-2005, 01:05 PM

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