Excel找文字框中的文字

文字框範例

解法

在需要搜尋的Excel表上輸入組合鍵開啟VBA編輯視窗

* 組合鍵: Alt+F11

並在左方VBAProject空白處

* 按右鍵->插入->模組

複製下方程式碼貼到新增的模組中:

Sub FindInShape()
    Dim rStart As Range
    Dim shp As Shape
    Dim sFind As String
    Dim sTemp As String
    Dim Response

    sFind = InputBox("找啥?")
    If Trim(sFind) = "" Then
        Exit Sub
    End If

    For Each shp In ActiveSheet.Shapes
        If shp.Type = msoAutoShape Then
            sTemp = Trim(shp.TextFrame2.TextRange.Characters.Text)
            If InStr(LCase(sTemp), LCase(sFind)) <> 0 Then
                shp.OLEFormat.Object.TopLeftCell.Select
                Response = MsgBox(prompt:=sTemp & vbCrLf, Buttons:=vbYesNo, Title:="繼續找嗎?")
                If Response <> vbYes Then
                    Set rStart = Nothing
                    Exit Sub
                End If
            End If
        End If
    Next
    MsgBox "沒有了啦~"
End Sub

點擊上方綠色執行鍵, 並輸入要找的字串即可

results matching ""

    No results matching ""