+ Reply to Thread
Results 1 to 9 of 9

VBA Command to delete the rows.

  1. #1
    Registered User
    Join Date
    09-23-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    56

    VBA Command to delete the rows.

    Hello,

    I have created the below macro code to delete all the rows containing "account" in column B.

    Can you please help me using the below VBA codes, using IF...THEN condition.

    Please Login or Register  to view this content.
    Last edited by mohan_rajun; 10-25-2010 at 06:44 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA Command to delete the rows.

    This is how I would write that:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

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

    Re: VBA Command to delete the rows.

    Try this
    Please Login or Register  to view this content.

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

    Re: VBA Command to delete the rows.

    Because you are shifting deleted rows up it might be better to count backwards instead of forwards. Change the For line to:

    Please Login or Register  to view this content.

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

    Re: VBA Command to delete the rows.

    I would advise you read through: http://www.xtremevbtalk.com/showpost...70&postcount=4

    ie if you intend to use AutoFilter then utilise SpecialCells etc...

    edit: full tutorial link: http://www.xtremevbtalk.com/showthread.php?t=300757
    Last edited by DonkeyOte; 10-25-2010 at 03:06 AM.

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

    Re: VBA Command to delete the rows.

    I think the Jerry's code will work quicker but may have a problem if there are blank rows.

    Excel people always assume users put data in well defined tables or lists.

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

    Re: VBA Command to delete the rows.

    Thanks for the link. I study now.

  8. #8
    Registered User
    Join Date
    09-23-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    56

    Re: VBA Command to delete the rows.

    Hi JBeaucaire,

    Thanks for the help... It worked out....

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA Command to delete the rows.

    Quote Originally Posted by mohan_rajun View Post
    Hi JBeaucaire,

    Thanks for the help... It worked out....
    My pleasure, glad it works for you.


    Quote Originally Posted by MarvinP
    I think the Jerry's code will work quicker but may have a problem if there are blank rows. Excel people always assume users put data in well defined tables or lists.
    I don't assume it, but I am prepared to counsel OPs to correct their data layout into standardized tables/lists when the "blanks in my design" does popup, part of what we have to do, eh?

+ 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