With ActiveWorkbook.Sheets("Incidents")
Set rFindIRID = .Range("F:F").Find(sIRID, LookIn:=xlValues, LookAt:=xlWhole) 'searches for presence of sIRID with "a" at the end
If rFindIRID Is Nothing Then 'Checks if sIRID value is already present in column F
sIRID = sIRID 'Since the value is not present, sIRID is not changed
ElseIf rFindIRID.Value = sIRID Then 'If sIRID is present Then
If Right(sIRID, 1) = "a" Then 'Checks if last character is "a" Then
sIRID = Left(sIRID, 14) & "b" 'Keeps 14 left characters and changes last character to "b"
Set rFindIRID = .Range("F:F").Find(sIRID, LookIn:=xlValues, LookAt:=xlWhole) 'searches for presence of new sIRID with a "b" at the end
If rFindIRID Is Nothing Then
sIRID = sIRID
ElseIf rFindIRID.Value = sIRID Then
If Right(sIRID, 1) = "b" Then
sIRID = Left(sIRID, 14) & "c"
Set rFindIRID = .Range("F:F").Find(sIRID, LookIn:=xlValues, LookAt:=xlWhole) 'searches for presence of new sIRID with a "c" at the end
If rFindIRID Is Nothing Then
sIRID = sIRID
ElseIf rFindIRID.Value = sIRID Then
If Right(sIRID, 1) = "c" Then
sIRID = Left(sIRID, 14) & "d"
Set rFindIRID = .Range("F:F").Find(sIRID, LookIn:=xlValues, LookAt:=xlWhole)
If rFindIRID Is Nothing Then
sIRID = sIRID
ElseIf rFindIRID.Value = sIRID Then
If Right(sIRID, 1) = "d" Then
sIRID = Left(sIRID, 14) & "e"
End If
End If
End If
End If
End If
End If
End If
End If
End If
End With
ActiveCell.Offset(0, 5) = sIRID