1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Excel 07 MACRO to delete rows/columns w/ criteria

Discussion in 'Business Applications' started by anamque, Jul 12, 2010.

Thread Status:
Not open for further replies.
  1. anamque

    anamque Thread Starter

    Joined:
    May 25, 2010
    Messages:
    29
    Hello - I found a previous post on this site that solves (I think) 90% of what I need to accomplish. I have a large spreadsheet that I need to:

    · Delete column C
    · Delete all rows without account numbers (Acct numbers will always be in column A)
    · Delete all rows that have dates in column F other than “00/00/0000”.

    The code I found on this site is :

    Simple vba code:
    lastrow = Range( "A65536").end(xlup).row
    For y = LastRow To 2 Step -1
    If Cells(y, x).Value = "" Then Cells(y, x).Delete shift:=xlUp
    Next y
    Set the range to the the column desired, in this case "A"
    Lastrow checks the last row and starts from the end up.
    Removes all empty rows entirely up to row 2 because row 1 generally is the header
    Happy coding


    Can anyone help me?
     
  2. turbodante

    turbodante

    Joined:
    Dec 19, 2008
    Messages:
    744
    If there are no acct numbers, will there be


    • blanks ""
    • Space " "
    • dash -
    • other ??
    Can you provide a sample with dummy data so we can see the data structure?
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/935095

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice