【发布时间】:2017-10-14 00:56:04
【问题描述】:
运行此代码时,我收到一个错误,即“没有执行的循环”。我想如果选择“case vbno”然后它返回到原来的输入框。如果用户选择“case vbyes”,我希望它突出显示然后单元格然后循环返回执行并返回到原始输入框。如果选择取消,我希望它完全退出。
Sub find_highlight3()
Dim w As Variant
Dim FoundCell As Range
Dim ans As String
Do
w = InputBox("What to find?")
Cells.Find(What:=(w), After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
With Selection.Interior
Select Case MsgBox("Hellow", vbYesNoCancel)
Case vbNo
Loop
Case vbYes
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
Loop
Case vbCancel
End Select
End With
End Sub
【问题讨论】:
标签: excel do-loops select-case vba