查找和格式化Excelmacros

我需要一个在Excel中的方式来通过我的整个工作簿,find所有的单词与一个匹配的案件,并将其添加到斜体。

我有像这样的数据单元格:

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. 

我需要把所有的“ESEA”改成斜体。

有没有办法在Excel中做到这一点,或者我需要一个macros?

以下代码将为您执行此操作:

 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