Last Updated on January 11, 2023 by token
1. MID VBA function – Description
The MID VBA function is equivalent to the SUBSTRING or SUBSTR function in other programming languages. How does the MID function work? The VBA MID function cuts text from other text. For example, from the sentence “I’m learning to program in VBA, we can cut out the word” programming “. How to do it? The syntax of the function and its example of use are presented below. The function can be compared to the FRAGMENT.TEXT from an Excel spreadsheet.
2. MID function – Syntax
The syntax for the Mid function is as follows:
MID (String, Start [, Length])
String – A text string from which to cut the text.
Start – The next position in the text string from which to start cutting the text. The argument is of the Long data type.
Length – Optional argument. We can define in it how many characters from the string we want to cut. If no argument is used, the return is the entire string starting at the position in Start.
Function return : String / text value
3. VBA Mid function – Example
How to use MID function in VBA Excel? Below is an example of using the MID function in the VisualBasic Editor.
Example 1: An example of using the Mid VBA function – result in the MsgBox window and a sheet cell.
Sub MidFunctionExample () MsgBox Mid ("Learning VBA Functions", 10) MsgBox Mid ("Learning VBA functions", 10, 7) Range ("A1") = Mid ("Learning VBA", 10, 7) MsgBox Mid (Range ("A1"), 1, 7) End Sub
4. VB Abs function – Additional information
- none
5. Abs VisualBasic function – Where to use?
The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel 2021, Excel 365.
The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address: VBA functions.