View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Macro for bolding and italicizing word strings

Hi,

I hope it's a typo and you don't want the v in italics because I just read
your post again before replying and the first part contradicts the last.
having written the code I'll post it anyway. Alt +F11 to open VB editor,
right click 'This workbook' and insert module and paste this in and run it

Sub Prime_Lending()
For Each c In ActiveSheet.UsedRange
If WorksheetFunction.IsText(c) Then
Findv = InStr(UCase(c.Value), "V")
If Findv <= 1 Then GoTo getmeout
If Mid(c.Value, Findv - 1, 1) < " " And Mid(c.Value, _
Findv + 1, 1) < " " Then GoTo getmeout
With c.Characters(Start:=1, Length:=Len(c.Value)).Font
.FontStyle = "Bold Italic"
End With
With c.Characters(Start:=Findv, Length:=1).Font
.FontStyle = "Regular"
End With
End If
getmeout:
Next
End Sub

Mike
"suestew" wrote:

I want to bold and italicize every word that comes directly before or after
"v."

For example, my sheet is full of cases cited as "Smith v. Jones" etc. I
want everything on each side of "v." to be bolded and italicized, including
the "v."