|Paste your chat log into an Excel worksheet, starting in A1.|
Click the Sheet tab and choose View Code.
Paste the code below into the window that opens
When run, it will ask the user for the DM's name. If it doesn't find that name in the log, it will ask the user again. The user can try again or cancel out of the program.
It will then loop through the log, deleting or retaining lines based on your criteria. When it finds a line without any of the Criteria specified, it will ask the user if they want to Retain that line. The user can say Yes, No or Cancel out of the program.
It's not perfect...
When entering the DM's name, if the user enters any string that the code can find, it will assume that that is the DM's name, even if the user made a typing error. With some more code, it's possible to fix that.
The Search routine isn't bulletproof. These lines would be retained, even though based on your criteria, the user should be asked what they want to do with the:
This line contains the DM's name, so it would be retained:
<@Lorelai> Is that something Widersinn made up or is it an actual clue leading us to do something?
This line contains quotation marks, so it would be retained.
<@Lorelai> Is that something you made up or is it an actual "clue" leading us to do something?
Both of these issues can probably be dealt with by adding more code, but I didn't want to do any more work if this solution does not fit your needs.
Dim nxtRow, firstSpace, lastChat_Line
Dim DM, no_DM, NotSure
'Get DM's name from user
DM = Application.InputBox("Enter DM's name")
If DM = False Then Exit Sub
'Make sure DM's name is found in log
If .Find(DM) Is Nothing Then
no_DM = MsgBox("DM's Name Not Found", vbOKCancel)
If no_DM = vbCancel Then Exit Sub
'Find row of last entry
lastChat_Line = Cells(Rows.Count, "A").End(xlUp).Row
'Delete Time Stamps
For nxtRow = 1 To lastChat_Line
firstSpace = Application.WorksheetFunction.Find(" ", Range("A" & nxtRow))
Cells(nxtRow, 1) = Right(Cells(nxtRow, 1), Len(Cells(nxtRow, 1)) - firstSpace)
'Loop through lines starting at bottom and working up
'You must start at the bottom when deleting lines
For Chat_Line = lastChat_Line To 1 Step -1
With Cells(Chat_Line, "A")
'If line contains a (, delete the line
If Not .Find("(") Is Nothing Then
'If line contains a * or " or the DM name, do not delete it
If Not .Find(DM) Is Nothing Or _
Not .Find("""") Is Nothing Or _
Left(Cells(Chat_Line, "A"), 1) = "*" Then GoTo Chk_Nxt
'If line doesn't fit any of the above criteria, query the user
NotSure = MsgBox(Cells(Chat_Line, "A") & vbCrLf & vbCrLf & "Retain?", _
vbYesNoCancel, "What about this line?")
If NotSure = vbNo Then .EntireRow.Delete
If NotSure = False Then Exit Sub