I am hoping to pull text from a cell in my active sheet, define that information as a string and pass it through this If, ElseIf, Else loop. The issue I'm facing is that even though the text I pull contains "dw" the output is always "Not Found".
Its strange because I use message box to see if ss is actually getting defined correctly and it does so I don't think my issue is with pulling the text or defining the string.
(It may not be necessary information but lrow changes because the code below is a part of a larger loop)
Dim ss As String
Dim iRow As Long
iRow = Cells.find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
lRow = iRow
ss = Cells(lRow, 5).Text
'the message box below shows me that ss is pulling the info from the sheet that I'm looking for
'msgbox (ss)
If InStr(ss, "dw") > 0 Then
Cells(lRow, 18).Formula = "=MID(E12,SEARCH(""dw""," & Chr(34) & ss & Chr(34) & "),6)"
ElseIf InStr(ss, "lex") > 0 Then
Cells(lRow, 18).Formula = "=MID(E12,SEARCH(""lex""," & Chr(34) & ss & Chr(34) & "),7)"
ElseIf InStr(ss, "tex") > 0 Then
Cells(lRow, 18).Formula = "=MID(E12,SEARCH(""tex""," & Chr(34) & ss & Chr(34) & "),7)"
ElseIf InStr(ss, "qex") > 0 Then
Cells(lRow, 18).Formula = "=MID(E12,SEARCH(""qex""," & Chr(34) & ss & Chr(34) & "),7)"
ElseIf InStr(ss, "qnxr") > 0 Then
Cells(lRow, 18).Formula = "=MID(E12,SEARCH(""qnxr""," & Chr(34) & ss & Chr(34) & "),8)"
Else
Cells(lRow, 18).Value = "Not Found"
End If
Aucun commentaire:
Enregistrer un commentaire