Be the first user to complete this post
|
Add to List |
VBA-Excel: String Functions – Mid()
Description:
The Mid() function returns substring from a string and size of the substring is decided based on the parameters provided.
Format:
Mid (strMainString,start[,length])
Arguments:
- strMainString
- Mandatory
- Type: String
- Substring will be returned from this main string.
- Start
- Mandatory
- Type: Numeric
- Starting position of a substring, if start > No Of characters in main string then Mid() will return zero-length string(“”).
- Length
- Optional
- Type: Numeric
- No of characters to be taken from the starting position. If not provided, all the characters after starting position are taken.
Function FnMid() Dim strMainString strMainString = "This is just an example" MsgBox "SubString is '" & Mid(strMainString, 2, 15) & "'" End Function
![Mid()](/static/media/excel/2013/05/Mid.jpg)
Also Read About Other String() Functions
INSTR() | InstrREV() | LCase()
Also Read:
- VBA-Excel: Array Functions – LBound and UBound()
- VBA-Excel: String Functions – Space()
- VBA Excel - Cells, Ranges and Offset: Refer to Cells by Using Shortcut Notation
- VBA-Excel: Date-Time Functions – DateAdd()
- VBA-Excel: Date-Time Functions – WeekDay() and WeekDayName()