PDA

View Full Version : Selecting: Just part of a string in a cell



nameuser321
04-15-2012, 09:56 AM
I'm pretty sure this is a simple question, but the answer continues to elude me. How can you have vba select a portion of the contents of a cell. For example, if i wanted vba to select just the "press" in "express" inside just one cell, how would I go about doing this?

mikerickson
04-15-2012, 11:23 AM
You could highlight (bold,color) that portion of the cell's contents. But selecting the characters can't be done. VBA doesn't interface with the formula editing box.


Dim someCell As Range
Dim subString As String
Set someCell = Sheet1.Range("C10")
subString = "press"
someCell.Characters(InStr(1, CStr(someCell.Value) & subString, subString), Len(subString)).Font.Bold = True