+ Reply to Thread
Results 1 to 17 of 17

Need macro to delete entries

  1. #1
    Registered User
    Join Date
    09-05-2011
    Location
    usa
    MS-Off Ver
    Excel 2007
    Posts
    10

    Need macro to delete entries

    Is it possible to have a macro that deletes entries based on different colored text or keywords, below is a document of some attack logs from a game and we were trying to filter out the unwanted ones (logs are on sheet 2 so to not clutter up the page, and members on sheet 1) using excel 2007. Basically the only good entries we would like to keep are in green where it says something like 10:42:43 PM H00D hospitalized ZetaXeno 06/09/11

    If its easier to look for the things that we dont want would be any lines in red heres a few samples but the color in general is unfavorable results
    10:19:34 PM T-Bohn hospitalized crunkenstein 06/09/11
    10:44:38 PM The_Ranger attacked Juan_Herndez and lost 06/09/11

    any lines in green that contain attacked or mugged such as
    10:44:38 PM The_Ranger attacked Juan_Herndez and lost 06/09/11
    10:20:33 PM H00D mugged Gamer 06/09/11


    The excel workbook posted is just a small sample of these we normally have 500-600+ entries in a day and thats to many to hand sort. The plan is to make an if statement or something like that, so that every time it seen H00d hospitalized in green it would add 1 to his total. Not sure how to do that part yet, tried if statements with =if * H00d hospitalized*, then if true count++ else blank but never got the logical part right.

    Also not sure how hard it would be to strip the time and date in the macro but its not needed at all just in the other cell when you copy from the webpage.
    Attached Files Attached Files
    Last edited by daniel0823; 09-09-2011 at 12:05 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Need macro to delete entries

    Hello daniel0823,

    Welcome to the Forum!

    The attached workbook will increment the point count for members if words "attacked" or "mugged" is found in the log. The time and date will also be removed.

    The macro ignores names found in the log that are not found in Members. However, they will be listed on log sheet. You didn't say if this condition would be problem or not. Let me know if want to handle this differently and I will correct it.

    Here are the two macros. Currently, you will need to manually run the macro "DeleteRows". It could be automated, but I would needed to know what would trigger it.

    Module1 Macros
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    09-05-2011
    Location
    usa
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Need macro to delete entries

    Thank you very much for that Leith Ross, needed it to only add the green hospitalized those are the members attacks won, the red hospitalizations are enemies, i tried to edit the macro and change attacked and mugged to hospitalized but when i ran the script it would delete the first letter of every members name and not add to the count. Not sure what i did to cause this, just changed attacked|mugged to hospitalized, and edited the comments as well to reflect this change. Was running macros in order they appeared in the list so delete row first then load member 2nd

    included it as an attachment to see
    Attached Files Attached Files
    Last edited by daniel0823; 09-07-2011 at 04:06 AM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Need macro to delete entries

    Hello daniel0823,

    The problem was with the time. I had written the code (foolishly) to expect 2 digits for hours, minutes, and seconds. By replacing the MID function with a Regular Expression, the macro is now more robust. Changes in the digits of either the time or date won't interfere with parsing the text between the two. Here is the updated macro. It has been installed in the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    09-05-2011
    Location
    usa
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Need macro to delete entries

    thank you so very much works like a dream now sure does cut down a lot of work. took me 2 hours to check charts 12 days worth of charts and break out the calculator to figure it all out. This way i can do that in 5-10 minutes

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Need macro to delete entries

    If you are happy with the results and your question has been answered, please mark your thread as solved.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  7. #7
    Registered User
    Join Date
    09-05-2011
    Location
    usa
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Need macro to delete entries

    found 1 small issue, if its not to hard to solve otherwise i can manually update the values. When pasting more then 1 page of attack logs, what would be the last one on the page gets messed up because theres no date at the end of it.. The first example looks to be from cell 467, i ran the macro then did a-z order to check for some guys that didnt get credit.

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

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Need macro to delete entries

    Hello daniel0823,

    I am not sure I follow what your saying. Can you post the workbook so I can follow along with what you're saying?

  9. #9
    Registered User
    Join Date
    09-05-2011
    Location
    usa
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Need macro to delete entries

    i did i added more entries to the logs page and kept the name the same. Its before i ran the macro so you can see the before and after, when you run the macro then sort it leaves the entries i posted above with time before the name. Those hits didnt get added to their totals i had to manually increase the count on them

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Need macro to delete entries

    Hello daniel0823,

    I updated the macro to check for both the time and date being present before extracting the member's name from the cell and updating the point count.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    09-05-2011
    Location
    usa
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Need macro to delete entries

    still looks to be doing the same thing, about every 25th row theres an entry that lacks the date then the 26th line contains a date with no info. Check soma for instance when you run it as is he would have 8 next to his name. But then you look at the logs that still have a time in the entry and you would find this one below

    12:22:28 AM Soma hospitalized thousand_miles

    which would make Soma's total 9, but since the time is still in front of the entry its not adding to the total. the same happens with each remaining entry after running the macro that has the time stamp in front of the entry. Reuploaded the latest version you had and put in all 500+ entries that i tried running the 1a and 1b versions with.

    Think the biggest problem is its trying to do a search for the time and date in an entry and if it lacks a date its skipping over it. With that in mind if it solves the problem easier you can take out the removing the date part and just removing the time would be helpful enough since thats before the name. With the time removed you can a-z order them and that works for me.

    P.S. sorry to be such a pain, i really appreciate the macro you have created for me.
    Attached Files Attached Files

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Need macro to delete entries

    Hello Daniel,

    If you don't care if the date and time is there or not, I need to know what the rules are to apply. Once you tell me what rules to apply to the time, date, and remaining text in between, we can move forward.

  13. #13
    Registered User
    Join Date
    09-05-2011
    Location
    usa
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Need macro to delete entries

    Not sure how to clearly explain it for you. I guess if you made another rule that removed time from an entry if it lacks a date at the end of the entry would solve the problem


    In the last one i uploaded when you run it you get all the correct results which would be a name hospitalized name. you also get a few entries these below. I looked in log and its because these entries appear exactly like that, theres 25 of them on the page when i copy them.

    When i paste them into excel it takes the first date and pastes it in its own cell. Then every date after gets stuck on the end of the next entry. So the 25th entry is left without a date at the end, and when you run the macro its leaving the time infront of the name, causing the hit counter to not increase on any of the entries below.

    Examples of entries after running the current macro that arent added to their totals
    Please Login or Register  to view this content.
    The text i do want is in the middle of the entrys like below. Need the name hospitalized name
    Hub_Master hospitalized RaReLy
    Last edited by daniel0823; 09-08-2011 at 12:49 AM.

  14. #14
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Need macro to delete entries

    Hello Daniel,

    It looks to me like the time and date are superfluous entities. The macro should check if they exist and if so remove them. Does that match with what you need?

  15. #15
    Registered User
    Join Date
    09-05-2011
    Location
    usa
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Need macro to delete entries

    yes but its not removing the time if they lack the date at the end, and that throws the counter off

  16. #16
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Need macro to delete entries

    Hello Daniel,

    Here is the revised macro which will remove the time and date if they are present to extract the member's name. If neither are present the member's name will still be extracted correctly. Here is the updated macro and workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    09-05-2011
    Location
    usa
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Need macro to delete entries

    sorry for the delay didnt realize this had went to 2nd page of posts, thanks that works perfect changing to solved now your a miracle worker!

+ 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