+ Reply to Thread
Results 1 to 4 of 4

Macro for Deleting the entire row if first two columns are blank

  1. #1
    Registered User
    Join Date
    09-20-2011
    Location
    Swiss
    MS-Off Ver
    Excel 2003
    Posts
    22

    Macro for Deleting the entire row if first two columns are blank

    Hi ,

    I am trying to write a macro which will delete the entire row if first two columns data is null. I have the below code but I am not sure how to get the workbook name as variable for WksName in the below code, I can't hard code the value as the worksheet names are dynamic and I have to run this code on regular basis for all the files in c:\test folder.

    Please suggest.

    Please Login or Register  to view this content.
    Thank you.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro for Deleting the entire row if first two columns are blank

    So the worksheet that you want to work on in each file that you open has the same name as the workbook containing the code?

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Macro for Deleting the entire row if first two columns are blank

    Is the sheet allways in the same position eg. first sheet in workbook

    then use the line

    Please Login or Register  to view this content.
    The you can make the check like this
    Please Login or Register  to view this content.
    Steffen Thomsen

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro for Deleting the entire row if first two columns are blank

    You will run into problems looping through a range like that and deleting rows. If you want to loop you must do it backwards or you will get odd results, another option is to use autofilter.

    Dom

+ 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