Home |
Search |
Today's Posts |
#9
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
One way:
Option Explicit Sub boldwordinstring() Dim myWord As String Dim Pos As Long myWord = "greater" Pos = 0 With ActiveCell Do Pos = InStr(Pos + 1, .Value, myWord, vbTextCompare) If Pos = 0 Then Exit Do Else 'found another one With .Characters(Start:=Pos, Length:=Len(myWord)).Font .FontStyle = "bold" End With End If Loop End With End Sub Miklo wrote: Hi Don, I know this post is really old but, I was wondering if you could tell me how to modify your code below to not only change the first instance of "greater" but, EACH instance? Thank you for your help! Miklo "Don Guillett" wrote: this is the idea. modify to suit needs. Perhaps a worksheet_change event? Sub boldwordinstring() pos = InStr(ActiveCell, "greater") With ActiveCell.Characters(Start:=pos, Length:=7).Font .FontStyle = "Regular" If pos 0 Then ' .Name = "Courier" .FontStyle = "Bold" ' .Size = 10 ' .Underline = xlUnderlineStyleNone ' .ColorIndex = xlAutomatic End If End With End Sub -- Don Guillett SalesAid Software "Goo" wrote in message ... For example any time a cell contains the text "greater" I would like the font for the word greater to be bold but not the other text in that cell. -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Cell Capacity - text | Excel Discussion (Misc queries) | |||
Changing cell format - for example text to numeric | Excel Discussion (Misc queries) | |||
How to change default cell format to "Text" | Excel Discussion (Misc queries) | |||
Possible Lookup Table | Excel Worksheet Functions | |||
Copy cell format to cell on another worksht and update automatical | Excel Worksheet Functions |