I have a workwook with multiple worksheets - I'm calling the macro to copy the formula down the column(s).
I'm having a problem replacing the active cell references from the recorded macro and passing in the correct worksheet references.
Here's the macro calling the various macros:
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 copy_subject_Column(ws) 'Copies the Subject Column to the from D to I
'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)
Call Replace_Re_Fw(ws) ' replaces the "RE": and "Fw:" to allow for date manipulation on the subject headers
Call Separate_Subject(ws)
End If
Next ws
Application.DisplayAlerts = False
Application.ScreenUpdating = True
End Sub
and here's the one i'm having problems with:
Sub Separate_Subject(ws As Worksheet)
'
' Separates the Subject Column into two columns, before **MIDART" and after **MIDART**
'
Range("J1").Select
ActiveCell.FormulaR1C1 = "Left Subject"
Range("J2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(FIND(""**MIDART**"",RC[-1])),RC[-1],LEFT(RC[-1],FIND(""**MIDART**"",RC[-1])-1))"
JRange("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("K2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(FIND(""**MIDART**"",RC[-2])),RIGHT(RC[-2],LEN(RC[-2])-FIND(""**MIDART**"",RC[-2])))"
Range("K2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(FIND(""**MIDART**"",RC[-2])),"""",RIGHT(RC[-2],LEN(RC[-2])-FIND(""**MIDART**"",RC[-2])))"
.Range("K2").Select
ActiveCell.AutoFill Destination:=Range(ActiveCell.Offset(0, -1), ActiveCell.Offset(0, -1).End(xlDown)).Offset(0, 1)
End Sub
Just not sure if this is the smartest way of doing this, or if im using the righth ws references here! cant seem to get my head round them! any help, gratefully received! Thanks
Bookmarks