

So you can use the functions under this object the same way you would use regular functions in Excel. The WorksheetFunction object is used as a container for Excel worksheet functions that can be used in VBA. If it did, then we used the WorksheetFunction.Find function to find the starting and ending position of the search string in the cell’s contents. We then used a for-loop to traverse over each cell ( m圜ell) in the range and we checked if the cell contained the search string. We used an InputBox to get the user’s search string input and we stored this text in the variable searchString. In this code, we stored the selected range of cells in the variable Rng. In our example, we entered the word “ King”. Type your search string in the input box. You will see a message window that asks you to enter your search string.M圜ell.Characters(WorksheetFunction.Find(searchString, m圜ell.Value), Len(searchString)).Font.Bold = True This can be achieved using the following module code: 'Code by Steve from Now, what if you only want to make the particular search string bold, instead of the entire cell?įor example, you might have a lot of data in your worksheet and you might want to bold only a particular word so that it stands out.
#How to center text in word cell how to#
How to Find and Bold Specific Text in a Cell using VBA If it did, then we made the contents of the cell bold. We then used a for-loop to traverse over each cell ( m圜ell) in the range and we checked if the cell contained the search string (using the InStr function). In this code, we again stored the selected range of cells in the variable Rng.

In our example, we entered the word “King”.
#How to center text in word cell code#

The next thing we need to do is to type the truncation formula in the cell where we want our first result to appear. įigure 1: Truncating text Step 3: Type the RIGHT or LEFT truncating formula in the target cell Note that if you are doing this for a whole column, then you will also have to prepare a whole column to display the truncated text. The next thing is to have a cell where you will have the truncated text string. Step 2: Select cell/column where you want the truncated text string to appear If you want to truncate characters for a whole column, you need to ensure that you have all the text string to truncate in one column. But if you do not have it, then you will have to enter it into a sheet. If you have a spreadsheet with the data, you can simply double-click on it to open. The first thing that you need to do in order to truncate characters is to have the data in a worksheet. In this post, we shall look at easy steps to truncate a cell. For you to do this, you have to learn how to use the trunc function. How to truncate text in Excel – Excelchatĭo you have text data in Excel that you want to truncate ? Well, in most cases, Excel users deal with text that needs to be shortened in order to be displayed the easy it should be.
