+ Reply to Thread
Results 1 to 6 of 6

VBA Code to Delete Rows in One Target Worksheet Based on Value Found in One Column

  1. #1
    Registered User
    Join Date
    07-02-2013
    Location
    Madison, WI
    MS-Off Ver
    Excel 2010
    Posts
    12

    VBA Code to Delete Rows in One Target Worksheet Based on Value Found in One Column

    Hi All.

    I am new to VBA, so please be nice

    I searched a bit online and I found things sort of close to what I need but didn't quite fit.

    I require a module with VBA code to do the following in sequence.

    For ONLY the worksheet named: PASTE CONST. METRICS DUMP HERE
    Find value in column R2:R20000 (or R:R whichever you think works better).
    If that value in column R is a date (non-blank) AND that date is prior to OR equal to the FIRST DAY OF THE CURRENT CALENDAR YEAR, then DELETE the corresponding row that value appears in. Any rows where column R is blank or has a date that falls in the current year should remain.
    Once all such rows have been deleted, select cell R2 (just beneath the column's heading) and Sort all data in range A2:V2000 from newest to oldest so that any rows where column R is blank are at the bottom.
    End of macro.

    Any thoughts on if a single code can do all this?


  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA Code to Delete Rows in One Target Worksheet Based on Value Found in One Column

    Try this:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-02-2013
    Location
    Madison, WI
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA Code to Delete Rows in One Target Worksheet Based on Value Found in One Column

    It appears to be infinite hourglassing.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA Code to Delete Rows in One Target Worksheet Based on Value Found in One Column

    Can you attach your workbook because it worked just fine in my test workbook?

  5. #5
    Registered User
    Join Date
    07-02-2013
    Location
    Madison, WI
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA Code to Delete Rows in One Target Worksheet Based on Value Found in One Column

    Sorry for the delay. I had to edit the file to make it less than 1MB or the site would not let me upload. Please advise and thank you for your time.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-02-2013
    Location
    Madison, WI
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA Code to Delete Rows in One Target Worksheet Based on Value Found in One Column

    The original file has almost 8500 rows of data in the target Sheet the macro is pointing at, so maybe it is choking due to the size? I just tried again and had to CTRL ALT DELETE to end Excel after five mins of hourglass.

+ 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