String & Character Functions
| ASC | Returns the ANSI number for the first character in a text string (Integer). |
| CHR | Returns the character with the corresponding ANSI number (String). |
| CSTR | Returns the expression converted to a string datatype (String). |
| FORMAT | Returns the text string of a number or date in a particular format (String). |
| INSTR | Returns the position of a substring within a larger string (Long). |
| INSTRREV | Returns the position of a substring within a larger string, from the end (Long). |
| JOIN | Returns a text string containing all the elements in an array (String). |
| LCASE | Returns the text string with all characters converted to lowercase (String). |
| LEFT | Returns a substring from the left of a string (String). |
| LEN | Returns the number of characters in a string (Long). |
| LIKE | This is a pattern matching operator. |
| LSET | Left justifies a string within a destination and fills the remainder with spaces. |
| LTRIM | Returns the text string without leading spaces (String). |
| MID - Function | Returns a substring from the middle, left or right of a string (String). |
| MID - Statement | Replaces a specified number of characters with characters from another string. |
| REPLACE | Returns the text string with a number of characters replaced (String). |
| RIGHT | Returns a substring from the right of a text string (String). |
| RSET | Right aligns a string within a string variable. |
| RTRIM | Returns the text string without trailing spaces (String). |
| SPACE | Returns the specified number of spaces (String). |
| SPLIT | Returns an array containing a specified number of substrings (Variant). |
| STR | Returns the text string of a number (String). |
| STRCOMP | Returns the result of a string comparison (Integer). |
| STRCONV | Returns the text string converted to a specific case or type (String). |
| STRING | Returns a repeating character of a given length (String). |
| STRREVERSE | Returns the text string with the characters reversed (String). |
| TRIM | Returns the text string removing leading and trailing spaces (String). |
| UCASE | Returns the text string with all the characters converted to uppercase (String). |
| VAL | Returns the numbers contained in a string as a numeric value of the appropriate data type (Double). |
| ASC Returns the ANSI number for the first character in a text string (Integer). |
| CHR Returns the character with the corresponding ANSI number (String). |
| CSTR Returns the expression converted to a string datatype (String). |
| FORMAT Returns the text string of a number or date in a particular format (String). |
| INSTR Returns the position of a substring within a larger string (Long). |
| INSTRREV Returns the position of a substring within a larger string, from the end (Long). |
| JOIN Returns a text string containing all the elements in an array (String). |
| LCASE Returns the text string with all characters converted to lowercase (String). |
| LEFT Returns a substring from the left of a string (String). |
| LEN Returns the number of characters in a string (Long). |
| LIKE This is a pattern matching operator. |
| LSET Left justifies a string within a destination and fills the remainder with spaces. |
| LTRIM Returns the text string without leading spaces (String). |
| MID - Function Returns a substring from the middle, left or right of a string (String). |
| MID - Statement Replaces a specified number of characters with characters from another string. |
| REPLACE Returns the text string with a number of characters replaced (String). |
| RIGHT Returns a substring from the right of a text string (String). |
| RSET Right aligns a string within a string variable. |
| RTRIM Returns the text string without trailing spaces (String). |
| SPACE Returns the specified number of spaces (String). |
| SPLIT Returns an array containing a specified number of substrings (Variant). |
| STR Returns the text string of a number (String). |
| STRCOMP Returns the result of a string comparison (Integer). |
| STRCONV Returns the text string converted to a specific case or type (String). |
| STRING Returns a repeating character of a given length (String). |
| STRREVERSE Returns the text string with the characters reversed (String). |
| TRIM Returns the text string removing leading and trailing spaces (String). |
| UCASE Returns the text string with all the characters converted to uppercase (String). |
| VAL Returns the numbers contained in a string as a numeric value of the appropriate data type (Double). |
Looping Through a String Concatenation
Dim iseperatepos As Integer
Do While Len(sText) > 0
iseperatepos = Instr(1, sText, ";")
If (iseperatepos > 0) Then
sCurrent = Left(sText, iseperatepos - 1)
sText = Right(sText, Len(sText) - iseperatepos)
Else
sCurrent = sText
sText = ""
End If
Loop
Remove Words with Numbers
Function RemoveWordsWithNumbers(s As String) As String
Dim a() As String
Dim i As Long
Dim r As String
a = Split(s)
For i = 0 To UBound(a)
If Not a(i) Like "*[0-9]*" Then
r = r & " " & a(i)
End If
Next i
If r <> "" Then
r = Mid(r, 2)
End If
RemoveWordsWithNumbers = r
End Function
Remove Last Element
This function will return the last element in a concatenated string.
Public Function RemoveLastElement(ByVal sConCat As String, _
ByVal sSeparatorChar As String) _
As String
RemoveLastElement3 = VBA.Mid(sConCat, VBA.InstrRev(sConCat, sSeparatorChar) + 1)
End Function
Public Function RemoveLastElement2(ByVal sConCat As String, _
ByVal sSeparatorChar As String) _
As String
Dim arArray As Variant
arArray = VBA.Split(sConCat, sSeparatorChar)
RemoveLastElement2 = arArray(UBound(arArray))
End Function
Public Function RemoveLastElement3(ByVal sConCat As String, _
ByVal sSeparatorChar As String) _
As String
Dim sreverse As String
Dim ifind As Integer
sreverse = VBA.StrReverse(sConCat)
ifind = VBA.Instr(1, sreverse, sSeparatorChar)
If (ifind > 0) Then
RemoveLastElement3 = VBA.StrReverse(VBA.Left(sreverse, ifind - 1))
End If
End Function
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext