From the course: Learning VBA in Excel (2019)

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Return part of a string

Return part of a string

From the course: Learning VBA in Excel (2019)

Start my 1-month free trial

Return part of a string

- [Narrator] Most people think of Excel as a number crunching application, which it is. But you can do a surprising amount with your VBA code to work with character strings. In this movie, I will show you how to assign parts of longer strings to a variable. My sample file is the Cut Strings workbook and you can find it in the chapter five folder of your exercise files collection. This workbook contains a single worksheet and in it, I have a list of case codes and within each of the codes, I have the year, the variety, and the batch. I've created three functions that will look into a case code and pull out the year, variety, and batch. So let me click in cell B2 and show you how it works for year. I'll type =case year and that is the name of the custom function that I created in VBA. And then A2 which is the case code. And when I press tab I get the year of 2018. So that is the first four characters at the left of the case code. I get the variety of olive oil by typing equal and I'm in…

Contents