Activating A Query from An Input Box

J

-JB-

Hi, and thanks in advance for any help....

This is for an Excel 2000 macro. I have a query input box where the
user can type in a query. I have a macro that will run that query, but
I don't know how to let the user activate it.

I want the user to be able to activate the query macro in either of two
ways:
By typing in the input box and pressing Enter, or by clicking on the
"Find" button next to the input box. The Input Box is simply merged
cells in the worksheet (cell G9 on the "UserPage"), not a pop up box.

I have no idea how to make the Enter key active the query macro, and
I'm having trouble getting the button to activate it. The Excel help
file says this (to run a macro from a button):
"Right-click a selection handle for the button or graphic control, and
then click Assign Macro on the shortcut menu.".
The problem is that option doesn't exist in the shortcut menu.

Any help would be greatly appreciated.

Jim
 
C

Chong Moua

You need to use events.

For Enter:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("G9").Address Then
'code here...
End If
End Sub

For Find button:

Private Sub Find_Click()
'code here...
End Sub

Either one of these will need to be placed on the Sheet
Code. Hope this helps...

Chong Moua
 

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