Be the first user to complete this post

  • 0
Add to List

VBA-Excel : Strings Functions – InstrRev

Description:

InstrRev: This function returns the position of last occurrence of a string into another string, as a variant, based upon the arguments are provided, OR you can say that it returns the position of the first occurrence of a string into another string from the end of the string.

Format:

InStrRev(mainString, searchedString[,start, ] [, compare])

Arguments:

  • mainString
    • Mandatory
    • Type: String
    • String being searched.

  • ·searchedString
    • Mandatory
    • Type: String
    • String to be searched
  • start
    • Optional
    • Type: Numeric
    • Starting position from where search has to be started.(from end of the string, if string length is 10 then it starts with 10 to 1)
    • Required if compare argument is specified
  • Compare
    • Optional
    • Specify type of string comparison.
    • Settings
ConstantValue
Description
vbBinaryCompare0Performs a binary comparison.
vbTextCompare
1Performs a textual comparison.
vbDatabaseCompare2Microsoft Access only. Performs a comparison based on information in your database.
INSTRRev
INSTRRev

Results:

ConditionResult
mainString is zero-length0
mainString is NULLNULL
searchedString is zero-lengthStart
searchedString is NULLNULL
searchedString is not found0
searchedString found in mainStringPosition at which match is found
Start> searchedString0
Function FnInstrRevOperations()

   Dim mainString

   Dim searchString

   mainString = "SumitJain"

   searchString = "i"

   MsgBox "Position of 'i' is " & InStrRev(mainString, searchString, 9, vbTextCompare)

   ' Output : Position is 'i' is 8
 

End Function

Also Read About  Other String() Functions

INSTR()                       |                         InstrREV()                       |                        LCase()

UCase()                      |                         Left()                                |                        Right()

LTrim()                        |                         Mid()                                 |                        Trim()

RTrim()                       |                        Replace()                          |                        Space()

Len()                           |                        StrComp()                         |                        String()



Also Read:

  1. VBA-Excel: Select and Activate Cells - Select
  2. VBA-Excel: String Functions – Replace()
  3. VBA-Excel: CurrentRegion
  4. VBA-Excel: Date-Time Functions – FormatDateTime()
  5. VBA-Excel: Create Array using Array() Function