![visual basic for excel module example visual basic for excel module example](https://www.excel-easy.com/smi/vba/examples/multiple-list-box-selections.png)
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.
![visual basic for excel module example visual basic for excel module example](https://www.excelcampus.com/wp-content/uploads/2017/01/Double-Click-a-Code-Module-to-View-Code-Window-in-VBA-Editor.png)
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.
VISUAL BASIC FOR EXCEL MODULE EXAMPLE 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.
![visual basic for excel module example visual basic for excel module example](https://www.techonthenet.com/excel/macros/images/visual_basic_editor2013_004.png)
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”. Copy the above code to your Visual Basic module window.Select the range of cells that you want to work with.SearchString = InputBox("Please Enter the Search String") This can be achieved by the following code: 'Code by Steve from Now consider a scenario where you need to highlight all the cells that contain a specific text using VBA. Then we used a for-loop to traverse over each cell ( m圜ell) in the range, making the contents of each selected cell bold, using the line: m圜 = True How to Bold Cells Containing a Specific Text using VBA