I have a macro where I'm trying to find the position of "E" or "H" in a variable length string, Bookname. Bookname has either an E or an H but not both. I tried using an IF statement
but I get "Expected Expression" on the IF.EHPosition = if(iserror(instr(Bookname,"E")=TRUE, EHPosition = instr(Bookname,"H"), _ EHPosition = instr(Bookname,"E"))
I then tried
but I get "Sub or Function Not Defined" for the IfError.EHPosition = IfError(InStr(BookName, "E"), InStr(BookName, "H"))
What to do?
Insr() returns 0 if not found, therefore:
EHPosition = InStr(BookName, "H") If EHPosition = 0 Then EHPosition = InStr(BookName, "E") End If
---
Ben Van Johnson
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks