I think this should get you started. This replaces the RXXXX with the Aaa,BBB(1000) style and also gets rid of the BU_zzz. You'll have to explain a bit more where else you want to go from there. Hope this helps.
Sub custom_delete()
Dim totalrange As Range
Dim check As Range
Dim LastRow As Long
'Find the last used row in a Column: column A in this example
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Set totalrange = Range("A1:A" & LastRow)
For Each check In totalrange
If InStr(check.Value, "R") = 1 Then 'check if it starts with R
'take the value of the first cell above it which normall has the
'Aaa.BBB(1000)-style code
tempstring = check.End(xlUp).Value
check.Value = tempstring
check.End(xlUp).Clear
ElseIf InStr(check.Value, "BU_") Then 'check if the value of the line starts with "BU-"
check.Clear
End If
Next check
End Sub
Bookmarks