You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
You will only be able to apply formatting to the entire contents of a cell. (It sounds like you want to highlight some of the contents of a given cell, but not other parts of that same cell.)
Actually there is a crude way you can "highlight" specific contents of a cell by changing the font attributes. Let's say you have selected the cell in which the text you want to "highlight" resides and you know the text start offset (intStart) in the cell and its length (intlength) then the following code should change that text's font attributes to "highlight" it
With ActiveCell.Characters(Start:=intStart, Length:=intLength).Font
.FontStyle = "Bold Italic"
.Size = 12
End With
You will probably want to play around with the FontStyle and Size depending on the attributes of the original text in the cell. There may be better solutions than this, but I don't know of any.
I just thought after I posted my response that you can also change the font colour and underline it by setting the .ColorIndex and .Underline properties in the same code. If this doesn't highlight your search results then I don't know what will.