excel如何使用通配符替换

excel如何使用通配符替换

在 Excel 中,我有如下数据

Series_post
Series_get

我想找到并替换它

<Series_post>
<Series_get>

我试过

find: Series*
replace: <Series*>

但其实它不起作用。它能找到细胞,但却<Series*>一直替换它们。

答案1

这种替换不是 Excel 中的标准功能,但可以使用 VBA 实现:

Sub wrap_in_tag()

    With ActiveSheet.Cells

        Dim c As Variant, firstAddress As String, sFind As String

        sFind = InputBox("Enter search critera, e.g. Series* will result <Series_test>:" _
        , "Enter Critera")

        If sFind = "" Then Exit Sub

        Set c = .Find(sFind, LookAt:=xlWhole)

        If Not c Is Nothing Then
            firstAddress = c.Address
            Do
                c.Value = "<" & c & ">"
                Set c = .Find(sFind, LookAt:=xlWhole)
            Loop While Not c Is Nothing
        End If
    End With
End Sub

答案2

最好的选择可能是Se<Set来替换t>

相关内容