+ Reply to Thread
Results 1 to 4 of 4

VBA code to remove rows in case of blank cells

  1. #1
    Registered User
    Join Date
    10-27-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    VBA code to remove rows in case of blank cells

    Hello I am trying to get the VBA code to delete a row if there is no data in a cell in that row. for example if D5 is blank delete row 5.

    I can get the Code to do this function row by row but I dont want to write it out 5000 times. Is there a formula to say repete function between rows 18-5000

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: VBA code to remove rows in case of blank cells

    Hi GrahamRoss, this one liner should do it (for the full column). If you want to do it for specific rows, just change D:D to something like D18:D5000.
    Please Login or Register  to view this content.
    Hope that helps!

  3. #3
    Registered User
    Join Date
    10-27-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: VBA code to remove rows in case of blank cells

    Can I add that to the botom of another sub routine it seems to just do the first one and then stop and not go onto delete the rows

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: VBA code to remove rows in case of blank cells

    You can certainly add it to the bottom of the first macro, or put it in a standard module and call it from the first macro. (e.g. "Call delrows")

    If the first macro is an event macro (Worksheet_Change, etc.) you may want to disable events at the beginning of the macro and then re-enable at the end so your change event isn't re-triggered.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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