Excel VBA Strings

This post will guide you how to use VBA String functions to manipulate the String in MS excel VBA.

There are many String Functions, which can be used to manipulate the string very effectively in excel as bellows:

Function Name & Description
InStr Returns the position of the first occurrence of the specified substring in a string. Search happens from the left to the right.
InstrRev Returns the position of the first occurrence of the specified substring in a string. Search happens from the right to the left.
Lcase Returns the lower case of the specified string.
Ucase Returns the upper case of the specified string.
Left Returns a substring (a specified number of the characters) from a text string, starting from the leftmost character.
Right Returns a substring (a specified number of the characters) from a text string, starting from the rightmost character.
Mid Returns a substring from a text string at the position that you specify.
Ltrim  

Returns a string after removing the spaces on the left side of the specified string.

Rtrim  

Returns a string after removing the spaces on the right side of the specified string.

Trim  

Returns a string value after removing both the leading and the trailing blank spaces.

Len  

Returns the length of the given string.

Replace Returns a string after replacing a string with another string.
Space Fills a string with the specified number of spaces.
StrComp Returns an integer value after comparing the two specified strings.
String  

Returns a string with a specified character for specified number of times.

StrReverse  

Returns a string after reversing the sequence of the characters of the given string.

Related Posts

How To Remove Special Characters in Excel
remove special character2

This post will show you how to remove special characters from text strings in Excel. And I am going to introduce two ways to remove special characters (@&)#%$) from a string in Excel. Removing Special Characters using Power Query If ...

How To Insert Comments in Protected Worksheet in Excel
insert commetns in protected workshee3

This post will show you how to allow comments in a protected worksheet in Excel. You can easily to insert comments into cells in a normal worksheet in Excel, but if want to insert a comment in a worksheet that ...

How To Convert Text to Upper Cases(Using VBA) in Excel
convert text to upper cases1

This post will show you how to switch from lower case to upper case in Excel. and I am going to show you two different ways of converting text to upper cases using formula or VBA macro in Excel 2013,Excel ...

How To Hide Every Other Row in Excel (Using VBA)
hide every other row1

This post will show you how to hide alternate rows or columns in Excel or how to hide every third, fourth, fifth row or column in Excel. If you want to hide every other row in your current worksheet, how ...

How to Disable the Save As Prompt in Excel
disable save as prompt1

This post will show you how to use a VBA Macro to save an Excel file and overwrite any existing file without a prompt so that you are going to get the little window that says file already exists do ...

How to Count Cells that Contain even or odd numbers in Excel
count cells that contain even numbers5

This post will guide you how to count the number of cells that contain odd or even numbers within a range of cells using a formula in Excel 2013/2016.How do I count cells that contain odd numbers through the use ...

How to Count Cells Are Not Blank or Empty in Excel
count non blank nonempty cells5

This post will guide you how to count cells that are not blank or empty in a given range cells using a formula in Excel 2013/2016.How do I count the number of cells that are not blank in a particular ...

How to Count Cells Less Than a Specific Value in Excel
count cells lessr than5

This post will guide you how to count the number of cells less than a particular numeric value in a given range cells using a formula in Excel 2013/2016. How do I count cells that are less than a specific ...

How to Count Cells Greater Than a Specific Value in Excel
count cells greater than 5

This post will guide you how to count the number of cells greater than a particular numeric value in a given range cells using a formula in Excel 2013/2016. How do I count cells that are greater than a specific ...

How to Remove All Extra Spaces and Keep Only One Between Words in Excel
How to Remove All Extra Spaces and Keep Only One Between Words 7

Sometimes when copying something from other type files to excel, there might be two or more spaces display between words. Extra spaces between words are frequently to be seen in excel, and this behavior is very annoying. If we want ...

Sidebar