+ Reply to Thread
Results 1 to 11 of 11

Macro to delete row if cell <> value...

  1. #1
    Registered User
    Join Date
    10-14-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007
    Posts
    67

    Macro to delete row if cell <> value...

    Hey guys,

    I need a short and simple macro that deletes any row that contains "*EDS*" in column A...this is the code I am using but it doesnt seem to be working correctly, it hangs up on line 2...

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    05-18-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Macro to delete row if cell <> value...

    Do the cells in column A only contain either *EDS* or no *EDS*? or are you trying to search through a paragraph of text for each cell in column A, and only delete if within that paragraph of text *EDS* shows up?

    Jason

  3. #3
    Registered User
    Join Date
    10-14-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro to delete row if cell <> value...

    No, the cells will have various information....EDS will just be in the middle of a lot of text.

    Example:

    HTML Code: 

  4. #4
    Registered User
    Join Date
    06-07-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010, Excel 2007
    Posts
    57

    Re: Macro to delete row if cell <> value...

    FinalRow = Cells(Rows.Count, 56).End(xlUp).Row
    For i = FinalRow To 1 Step -1

    If Cells(i, 1).Value = "*EDS* Then
    Cells(i,1).Delete
    End If

    Next i

  5. #5
    Registered User
    Join Date
    05-18-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Macro to delete row if cell <> value...

    Hi,

    try changing
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    OR replace entirely with this code ..

    Please Login or Register  to view this content.
    Last edited by jasondu; 06-22-2012 at 12:03 PM.

  6. #6
    Registered User
    Join Date
    10-14-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro to delete row if cell <> value...

    Jason, that does work - however I had to run it 3 times in order for it to delete all the EDS rows...
    For some reason it is not catching them all in one run...i am going to try it a couple more times

  7. #7
    Registered User
    Join Date
    05-18-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Macro to delete row if cell <> value...

    hmm it shoudlve deleted all (it worked for me), but anyways see modified post I fixed your code for a even simpler solution

  8. #8
    Registered User
    Join Date
    10-14-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro to delete row if cell <> value...

    I managed to work around it and add it 3 ways...not the best way to do it, but it works lol -

    Also one more question, what is the code change for application.match if say I didnt want it to match "*EDS*". If that makes sense...

    So logic would be: If it does not equal "*EDS*" then delete entire row.

  9. #9
    Registered User
    Join Date
    10-14-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro to delete row if cell <> value...

    I appreciate all your help with this

  10. #10
    Registered User
    Join Date
    05-18-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Macro to delete row if cell <> value...

    Hey Tshelt,

    Did you try changing
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Also .. do you have any blanks in column A? how many rows do you have? I tried my code and it worked for up to 300 lines with varying *EDS* in random text can you upload your sheet?
    Last edited by jasondu; 06-22-2012 at 12:26 PM.

  11. #11
    Registered User
    Join Date
    10-14-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro to delete row if cell <> value...

    I cannot upload my sheet as it has info on it I dont want out...

    The sheet has 365 rows but it varies weekly and no blanks.

+ 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