Excel VBA搜索按钮 [英] Excel VBA Search Button
问题描述
我正在尝试使用一个文本框和命令按钮来搜索整个工作簿中的特定字词或值。例如3132或工作说明。到目前为止,我可以搜索我的工作表,但我无法搜索工作簿的其余部分。另外,一些工作表是隐藏的。任何对此的洞察将是有益的,并帮助我一吨!我已经列出了我的修改程序:
I am trying to use a text box and command button to search my entire workbook for a specific word or value. For example, "3132" or "Work Instructions". So far I am able to search the sheet that I am on but I cannot search the rest of the workbook. Plus, some of the worksheets are hidden. Any insight to this would be beneficial and help me out a ton! I have listed my currect program below:
Private Sub CommandButton6_Click()
Dim strFindWhat As String
strFindWhat = TextBox1.Text
On Error GoTo ErrorMessage
Cells.Find(What:=strFindWhat, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Select
Exit Sub
ErrorMessage:
MsgBox ("The data you are searching for does not exist")
End Sub
有一个好的! / p>
Have a good one!
推荐答案
您需要循环遍历 workbook.worksheets $ c $中的工作表对象数组c> collection。
You need to loop through the array of worksheet objects in the workbook.worksheets
collection.
这篇关于Excel VBA搜索按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!