I need a way in excel to go through my entire workbook and find all the words with a matching case and add them into italics.
I have cells with data like so:
Percentage of CTE concentrators who have met the proficient or advanced level on the
statewide high school mathematics assessment administered by the state under ESEA and
who, in the reporting year, left secondary education.
I need to change all the "ESEA" into italics.
Is there a way to do this in excel or do I need a macro?
Here's code that will do this for you:
Sub Macro1()
Dim sFirstAddress As String, rgFound As Range
Const sSearch As String = "ESEA"
Set rgFound = Cells(1, 1)
Do While Not rgFound Is Nothing
Set rgFound = Cells.Find(What:=sSearch, After:=rgFound, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True, _
SearchFormat:=False)
If rgFound.Address = sFirstAddress Then Exit Do
If InStr(rgFound.Value, sSearch) > 0 Then
If Len(sFirstAddress) = 0 Then sFirstAddress = rgFound.Address
rgFound.Characters(InStr(rgFound.Value, sSearch), Len(sSearch)).Font.FontStyle = "Italic"
End If
Loop
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.