'Convert all specified text on Worksheet into italic font
Sub ItalicFont()
Dim rNa As Range
Dim FindIt As String
Dim strAddy As String
'Application box so the specific word is entered and searched for
Prompt = "What is the value you want to apply the bold font to?"
Title = "Search Value Input"
FindIt = InputBox(Prompt, Title) Set rNa = ActiveSheet.UsedRange.Find(What:=FindIt, LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True)
If Not rNa Is Nothing Then
strAddy = rNa.Address
Do
'make the specific word bold
rNa.Font.Italic = True
' add any other formatting required here
Set rNa = ActiveSheet.UsedRange.FindNext(rNa)
Loop While rNa.Address <> strAddy
End If
End Sub
'Convert all specified text on Worksheet into non-italic font
Sub RemoveItalicFont()
Dim rNa As Range
Dim FindIt As String
Dim strAddy As String
'Application box so the specific word is entered and searched for
Prompt = "What is the value you want to apply the bold font to?"
Title = "Search Value Input"
Set rNa = ActiveSheet.UsedRange.Find(What:=FindIt, LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True)
If Not rNa Is Nothing Then
strAddy = rNa.Address
Do
'make the specific word bold
rNa.Font.Italic = False
' add any other formatting required here
Set rNa = ActiveSheet.UsedRange.FindNext(rNa)
Loop While rNa.Address <> strAddy
End If
End Sub
No comments:
Post a Comment