ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change format of single word in cell (https://www.excelbanter.com/excel-programming/302132-change-format-single-word-cell.html)

Zenon

Change format of single word in cell
 
Hi,

I need to search and highlight (using bold, change color or whatever
single words in Excel using VBA. With find method, I can find them, bu
when using the replace method, always the complete cell, in which th
word has been found, will be highlight.

Any idea??

Thanks and regards,
Zeno

--
Message posted from http://www.ExcelForum.com


Bernie Deitrick

Change format of single word in cell
 
Zenon,

You need to use the characters method once you've found the word:

Dim myStr As String
ActiveCell.Value = "This word is bold and red."
myStr = "word"
With ActiveCell.Characters(Start:=InStr(1, ActiveCell.Value, myStr), _
Length:=Len(myStr)).Font
.FontStyle = "Bold"
.ColorIndex = 3
End With

As for integrating this into your code, we would need to see your code to do
that....

HTH,
Bernie
MS Excel MVP

"Zenon " wrote in message
...
Hi,

I need to search and highlight (using bold, change color or whatever)
single words in Excel using VBA. With find method, I can find them, but
when using the replace method, always the complete cell, in which the
word has been found, will be highlight.

Any idea??

Thanks and regards,
Zenon


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 09:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com