0

我需要在 excel 中找到一种方法来浏览我的整个工作簿并找到所有具有匹配大小写的单词并将它们添加到斜体中。

我有这样的数据单元格:

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中做到这一点还是我需要一个宏?

4

1 回答 1

2

这是将为您执行此操作的代码:

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
于 2012-11-12T20:22:54.213 回答