I have these excel files that contain either Yes or No in column E, and a text string in column D.
If column E on a row is Yes, AND if there is no letter J at the end of the string in column D, then J needs to be added to the end.
so in the screenshot below, the value in D8 needs to be F21223AJ, the value in D26 needs to be F21233AJ
my code below doesnt seem to work, and would you take the same approach to solve this problem ?
If column E on a row is Yes, AND if there is no letter J at the end of the string in column D, then J needs to be added to the end.
so in the screenshot below, the value in D8 needs to be F21223AJ, the value in D26 needs to be F21233AJ
my code below doesnt seem to work, and would you take the same approach to solve this problem ?
VBA Code:
Sub StockPiecesWithHoleAddJ()
Dim lr As Long, i As Long
Set rng2 = Range("A1").CurrentRegion
lr = rng2.Cells(Rows.Count, "D").End(3).Row
For i = lr To 2 Step -1
If rng2.Cells(i, 5) Like "Yes" And _
Not rng2.Cells(i, 4) Like "*J*" Then
rng.Cells(i, 4) = rng.Cells(i, 4) & "J"
End If
Next i
End Sub