Link to home
Start Free TrialLog in
Avatar of Billa7
Billa7

asked on

Add If Condition

Please help. How to add one more if condition in the attached script:

If Column D with "DK/TypeKL10/5 F185" , change into "New Entries" 

 
Sub Update_Type()

Dim xLast_Row As Long
Dim xCell As Range
Dim xHold As String
Dim n As Long
Dim rFind As Range

Sheets("Data").Activate

xLast_Row = Range("A1").SpecialCells(xlLastCell).Row

n = 6
For Each xCell In Range(Cells(n, "D"), Cells(xLast_Row, "D"))

    If xCell.Offset(0, -3) <> "" And InStr(xCell, "TypeAA") = 0 And InStr(xCell, "Match") = 0 And _
    InStr(xCell, "LostS") = 0 Then
        xHold = xCell
        If Mid(xHold, 1, 3) = "(L)" Then
            xCell = "TypeAA"
        ElseIf Mid(xHold, 1, 4) = "(FR)" Then
            xCell = "Match"
        Else
            xCell = "LostS"
        End If
    
    End If
Range("C4") = "_Issued on " & Format(Now, "mm.dd.yyyy"" @ ""hhmm")
Next xCell

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of chwong67
chwong67
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Billa7
Billa7

ASKER

Hi,

Thanks for the revised code. I need your help, sometime I noticed the code update cell D5 as well with "LostS". By right any update should be after row 5.  Is that a way to prevent this?
n=6 indicates that the loop started with row 6.
Do you have any sample for this exceptional case?
Avatar of Billa7

ASKER

Hi chwong67,

In fact I can't really trace at what condition this thing happen:(
In this macro, there is control for the loop (started with row 6).
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Billa7

ASKER

Thanks for the help