Hi there,
Not sure about your 'expected outcome' for rows 2 & 3 as the first filter in column BL is not LAG, hence not met.
Try the attached file.
The code below will output the result in column 'BN' for testing. Just update 'BN' with 'BG' once happy with the code.
Option Explicit
Sub ReplaceText()
Dim lRow, i As Long
lRow = Cells(Rows.Count, "BG").End(xlUp).Row
For i = 2 To lRow
If Cells(i, "BL").Value = "LAG" And _
(Cells(i, "BF").Value = "OCOGS - Spares - Transfer Price Overhead" Or _
Cells(i, "BF").Value = "OFSS - ORCL Consulting Prod Cost I/C") Then
If (Cells(i, "AY").Value = "BOA_033E" Or _
Cells(i, "AY").Value = "BOA_011G") Then
Cells(i, "BN").Value = "OCOGS - Spares - Transfer Price Overhead"
Else
' Change "BN" to "BG" after testing and validation
Cells(i, "BN").Value = "OFSS - ORCL Consulting Prod Cost I/C"
End If
Else: Cells(i, "BN").Value = ""
End If
Next
End Sub
Bookmarks