Create a search Field within a worksheet to search command buttons

E

Ed P

I have a Workbook created with a page I refer to as the Table of Contents.
Within this page I have approx. 75 different Command Buttons that redirect to
a worksheet within the workbook. Can anyone tell me how to create a Search
field on this page that will locate and redirect the user to that command
button on the page.
Thank you for your help
Ed
 
T

Tom Ogilvy

Possibly:

Dim sh as Worksheet, oleObj as OleObject
SearchString = InputBox("Enter Sheet Name")
if SearchString = "" then exit sub
on Error Resume Next
set sh = Worksheets("SearchString")
On Error goto 0
if sh is nothing then
msgbox "No such sheet"
exit sub
End if

for each oleobj in activesheet.OleObject
if type of oleobj is MSForms.Commandbutton then
if oleObj.Caption = SearchString then
oleObj.Activate
exit for
end if
end if
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top