VBA搜索不带msgBox,但带有用户窗体

时间:2018-08-13 15:40:12

标签: excel vba excel-vba

使用自定义用户表单而不是msgbox可以实现此代码吗?因为无法使用自定义按钮来编辑msgbox。我想在msgbox设计之后继续循环。我知道用vba是不可能的,但是有办法吗? 代码:

Sub Forward()

    StrVal = UserForm1.TextBox3.Text
    If Trim(UserForm1.TextBox3.Text) = "" Then Exit Sub

    For Each ws In ThisWorkbook.Worksheets

        fstAddress = ""
        With ws
            Set Loc = .Cells.Find(what:=StrVal, LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlNext)
            If Not Loc Is Nothing Then
                Do
                    fstAddress = fstAddress & "|" & Loc.Address

                    Loc.Parent.Activate 'Activate the correct sheet.
                    Loc.Activate        'and then the cell on the sheet.

                    bDecision = MsgBox("Weitersuchen?", vbYesNo + vbQuestion, "Replace or Select value?")

                    If bDecision = vbYes Then
                        Set Loc = .Cells.FindNext(Loc)
                    End If

                    If Loc Is Nothing Then Exit Do
                Loop While InStr(fstAddress, Loc.Address) = 0
            End If
        End With
    Next ws

End Sub

这项工作会吗?: http://shutupdean.com/blog/2014/08/01/vba-msgbox-custom-button-text/

0 个答案:

没有答案