+ Reply to Thread
Results 1 to 9 of 9

If/Then Loop to find Matches in Column

  1. #1
    Registered User
    Join Date
    08-10-2007
    Posts
    34

    If/Then Loop to find Matches in Column

    Ok, this one shouldn't be that hard.

    I'm looking to go down column A, and find all of the doubled (or tripled, quad... ect) values. I originally would manually insert a cloumn, and write an "if" function to place an X if the cell R[-1]C[-1] was equal to the cell RC[-1]. I'd then run the macro to delete them. However, I want to have it all automated, so i'm trying to do that here in the top of the macro here.

    (The if/then loop)

    It doesn't work . The erasing of rows that have X's works fine. It's just that I cant get the macro to place X's.


    Please Login or Register  to view this content.

    Thanks,


    `Ryan
    Attached Files Attached Files

  2. #2
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Hi engineers08,

    Assuming that Row 1 contains headers I have adjusted your code and it should work:

    Please Login or Register  to view this content.
    Last edited by SOS; 06-03-2008 at 06:14 PM. Reason: Wrong sheet selected in code
    Hope this helps

    Seamus

  3. #3
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    But wait,

    In your example Username in Cell A3 is 100100523 with a FirstLaunch in Cell B3 of 13/03/2008 and the same Username is in Cell A4 with a FirstLaunch in Cell B4 of 03/04/2008:

    The code you wrote (and that I modified) will insert a column and place an X in Cell B3 (because the value of A3 = the value of A4). The rest of the code will then delete the whole row 3. Is that what you want?

    I should also have added another line to the code to delete the column that was added to house the "X's"

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-10-2007
    Posts
    34

    Great!

    SOS, you're awesome!

    Just checked it on my sample sheet, then made the changes neccisary to apply it to the real deal.



    I have one more question here...

    Say I had another column, that was already populated by three different variables. We can call them "Complete", "incomplete", and "not started". If I wanted to delete all the rows that had "incomplete" or "not started" in them, how would I go about including that in my row deletion function.

    Would I have to write 2 extra autofilter statements? Or could I somehow include them in there? I think it would be easier if we did it before the "X" delete function.

    I've updated my example sheet, please take a look?

    Thanks a lot!
    `Ryan
    Attached Files Attached Files

  5. #5
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Engineers08

    Updated file attached which should do what you need. Let me know if it doesn't.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    08-10-2007
    Posts
    34
    I've messed with it for a while. It just seems to erase all of the data when I put it into my sheet.

    It also gives me an error on the line:

    Please Login or Register  to view this content.
    Last edited by Engineers08; 06-04-2008 at 02:06 PM.

  7. #7
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Hi Engineers08

    Looked at it again and tweaked the code to check if Autofilter is on or off and switch it on or off accordingly

    It seems to work for me.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    08-10-2007
    Posts
    34

    Thumbs up

    Yeah, my bad. I had a bad day on other projects and forgot to change the autofilter feild ID in when I ported it to my new doc. I also had to add another filter before adding the "X"s to make sure I got em all.


    Thanks a million, you've not only helped me out, but taught me about the autofilters.


    Cheers!
    `Ryan

  9. #9
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Your'e welcome, Ryan.

    I enjoy trying to help the folks on here as well.

    Regards

    Seamus

+ 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