Excel Mid Function (VBA): Find a String of Characters | Excel Help
Your Programming and Traning Professionals

Excel Mid Function (VBA): Find a String of Characters


The Excel MID VBA function finds a string of characters in a Variant starting from the position you specify.


MID(stringvariable, starting point[, length])

StringVariable: Put a variable in that has the string

Starting Point: character to begin function at (integer)

Length: number of characters to replace, you can omit this)

Example:

Dim EditString As String 
EditString = Activesheet.cells(10,3).value 'Sets the variable for the string
'For this example, say EditString = "test"
GetMID = Mid(editstring,2) 'Mid Function in use
GetMid returns "est" since you are starting at the 2nd character with the
MID function