HomeVBA Functions LIST (Category Wise)How to use the VBA INSTRREV Function (Syntax + Example)

What is VBA INSTRREV Function

The VBA INSTRREV function is listed under the text category of VBA functions. When you use it in a VBA code, it returns the starting position number of a sub-string (specified by you) from another string. Unlike INSTR, it starts searching for the sub-string from the right side of the string, which means the end to start.

how to use it

To use VBA's INSTRREV function you need to understand its syntax and arguments:


InStrRev(StringCheck, StringMatch, [Start], [Compare])


  • StringCheck: The string in which you want to search.
  • StringMatch: The string that you want to search for.
  • [Start]: An integer to specify the position from where you want to start the search [This is an optional argument and if omitted VBA takes 1 by default].
  • [Compare]: A string value to define the comparison to make while filtering array [This is an optional argument and if omitted VBA takes vbBinaryCompare by default].
    • vbBinaryCompare: For binary comparison.
    • vbTextCompare: For text comparison.
    • vbDatabaseCompare: For Database Comparison. 

Example to use INSTRREV Function in VBA

To practically understand how to use VBA INSTRREV function, you need to go through the below example where we have written a vba code by using it:

Sub example_INSTRREV()
Range("B1").Value = InStrRev(Range("A1"), " ")
End Sub

In the above code, we have used the INSTRREV to find the space within the value (Excel Champs) in cell A1 and it has returned 6 as a result, there’s the first space is between “Excel” and “Champs” whose position is 6.


Below are some important points which you need to take care while using INSTRREV function in VBA.

  • If "stringcheck" or "stringmatch" is NULL then it will return NULL in the result.
  • If "stringmatch" cannot be found in "stringcheck" then it will 0 is the result.

Related Functions

About the Author

puneet one point one

Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can find him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.