Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Dissecting a String.
Written by Allen Wyatt (last updated February 23, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
If you have used BASIC before, you will be right at home with the string functions provided by VBA. The following table details the most common string functions and what they return.
Function | Comments | |
---|---|---|
Left(Source, Count) | Returns the left Count characters of Source text. | |
Mid(Source, Start [, Count]) | Returns the portion of Source text beginning with the Start character. If Count is supplied, then the result is limited to that many characters. | |
Right(Source, Count) | Returns the right Count characters of Source text. |
Remember that these are VBA functions, not worksheet functions. Excel provides worksheet functions that do largely the same things, but those functions place different requirements on which parameters are required and which are optional.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12574) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Dissecting a String.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
Need to gather some information about the drives on a system? It can be pretty easy to do using a macro, as shown in this ...
Discover MoreWhen sharing workbooks with others, you may find that the macros in those workbooks may not work as you expect. This tip ...
Discover MoreWrite out a check and you need to include the digits for the amount of the check and the value of the check written out ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2018-03-10 10:43:26
Brian L.
One of my favorites is the SPLIT function -- very useful for break up strings into component parts, based on a specified delimiter. See https://msdn.microsoft.com/en-us/library/6x627e5f(v=vs.90).aspx ("archived" article, but has good examples).
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments