Sub Perform_Data_Cleanup()
Dim ws As Worksheet
Application.DisplayAlerts = False
Application.ScreenUpdating = False
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Control" Then
Call Text_to_Column_Comma(ws) 'run text to columns macro on all worksheets (Comma)
Call DeleteColumnF(ws) 'run delete columnf macro on all worksheets
Call copy_subject_Column(ws) 'run copy subject column macro on all worksheets
Call Replace_Re_Fw(ws) 'run remove RE: and FW: from column G on all worksheets
'Call Text_to_Column_dash(ws) 'run text to columns macro on all worksheets (Dash)
Call Fill_Date(ws)
End If
Next ws
Application.DisplayAlerts = False
Application.ScreenUpdating = True
End Sub
Sub Text_to_Column_Comma(sh As Worksheet)
'
' Text_Columns1 Macro
' Macro to separate Text to Columns where the delimiter is ,
'
sh.Columns("A:A").TextToColumns Destination:=sh.Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, OtherChar:=",", _
FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, _
4), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1)), TrailingMinusNumbers:=True
End Sub
Sub DeleteColumnF(wrk As Worksheet)
'
' DeleteColumnF Macro
wrk.Columns("F:F").Delete Shift:=xlToLeft
End Sub
Sub copy_subject_Column(ASheet As Worksheet)
ASheet.Range("D:D").Copy
ASheet.Range("H1").PasteSpecial Paste:=xlPasteValues
ASheet.Columns("D:D").Delete Shift:=xlToLeft
End Sub
Sub Text_to_Column_dash(ws As Worksheet)
'
' Text_Columns1 Macro on Asterisk
' Macro to separate Text to Columns where the delimiter is -
'
ws.Columns("G:G").TextToColumns Destination:=ws.Range("G1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar:="-", _
FieldInfo:=Array(1, 1), TrailingMinusNumbers:=True
End Sub
Sub Replace_Re_Fw(ws As Worksheet)
ws.Cells.Replace What:="Re: ", Replacement:="", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
ws.Cells.Replace What:="Fw: ", Replacement:="", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
Sub Fill_Date(ASheet As Worksheet)
Dim Cl
For Each Cl In ASheet.Range("G:G").SpecialCells(xlBlanks).ASheet.Cells
Cl.Value = ASheet.Range("D" & Cl.Row).Value
On Error GoTo 0
Next
End Sub
Sub Separate_Subject()
'
' Separates the Subject Column into two columns, before **MIDART" and after **MIDART**
'
Range("I1").Select
ActiveCell.FormulaR1C1 = "Left Subject"
Range("I2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(FIND(""**MIDART**"",RC[-1])),RC[-1],LEFT(RC[-1],FIND(""**MIDART**"",RC[-1])-1))"
Range("I2").Select
ActiveCell.AutoFill Destination:=Range(ActiveCell.Offset(0, -1), ActiveCell.Offset(0, -1).End(xlDown)).Offset(0, 1)
Range("J1").Select
ActiveCell.FormulaR1C1 = "Right Subject"
Range("J2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(FIND(""**MIDART**"",RC[-2])),RIGHT(RC[-2],LEN(RC[-2])-FIND(""**MIDART**"",RC[-2])))"
Range("J2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(FIND(""**MIDART**"",RC[-2])),"""",RIGHT(RC[-2],LEN(RC[-2])-FIND(""**MIDART**"",RC[-2])))"
Range("J2").Select
ActiveCell.AutoFill Destination:=Range(ActiveCell.Offset(0, -1), ActiveCell.Offset(0, -1).End(xlDown)).Offset(0, 1)
End Sub
Bookmarks