Name
InstrRev Function
Syntax
InstrRev(sourcestring,soughtstring[,start[,compare]])
sourcestringUse: Required
Data Type: String
The string to be searched.
soughtstringUse: Required
Data Type: String
The substring to be found within
sourcestring.startUse: Optional
Data Type: Numeric
Starting position of the search. If no value is specified,
startdefaults to 1.compareUse: Optional
Data Type: Integer
The method that compares
soughtstringwithsourcestring; its value can bevbBinaryCompareorvbTextCompare
Return Value
Variant of type Long.
Description
Determines the starting position of a substring within a string by searching from the end of the string to its beginning.
Rules at a Glance
While InStr searches a string from left to right, InStrRev searches a string from right to left.
vbBinaryCompareis case-sensitive; that is, InstrRev matches both character and case, whereasvbTextCompareis case-insensitive, matching only character, regardless of case.The default value for
compareisvbBinaryCompare.startdesignates the starting point of the search and is the number of characters from the start of the string.If
startis omitted, the search begins from the last character insourcestring.sourcestringis the complete string in which you want to find the starting position of a substring.If
soughtstringisn’t found, InStrRev returns 0.If
soughtstringis found withinsourcestring, the value returned by InStrRev is the position ofsourcestringfrom the start of the string.
Programming Tips and Gotchas ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access