+ Reply to Thread
Results 1 to 4 of 4

delete Entire Row if specified word exist

  1. #1
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    delete Entire Row if specified word exist

    Hi
    In range A1:A300 I have a lotof words. What I want is to delete entire row if the cell value is Open date

    My code is
    Please Login or Register  to view this content.
    But doesnt workind. It just loops...
    Last edited by teylyn; 12-12-2009 at 05:19 AM.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: elete Entire Row if specified word exist

    CWE, you should (to avoid sledgehammer) use Auto Filter or even use Find loop or temp formulae column and specialcells...

    However, all that being said, to demonstrate the Loop syntax given this is the what you're trying to get to grips with (I think):

    Please Login or Register  to view this content.
    Points worth noting in the above

    1 - always work bottom to top when deleting anything

    2 - avoid .Select as this is rarely warranted and slows your code

    3 - note VBA by default is case sensitive (the opposite of native XL) so if you wish to conduct case insensitive comparisons you should ensure case sensitivity is removed either by:

    a) ensuring all values are in common case (as above via UCase)

    b) using Option Compare Text at head of Module

  3. #3
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: elete Entire Row if specified word exist

    GREAT THANX !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    but one more question. When I work bottom to top, do I have to always use step -1, or what will happen if I dont do this?
    Thanks again...

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: elete Entire Row if specified word exist

    Yes. The best thing to do is work through logically what's happening...

    If you iterate 1 to 10 (top -> bottom) and delete say row 5 then when you iterate to 6 you're really jumping to the original row 7 given what was row 6 is now row 5 (original row 5 removed).

    This is why we say iterate 10 to 1 ... when you do this when you get to row 5 and delete it the step -1 moves you from 5 to 4 ... row 4 is unaffected by the removal of row 5 ... as we know from before it is only the rows below the old row 5 (6 to 10) that will have been affected and that will have shifted upwards (ie now 5-9)

+ 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