LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Assign Function to a Command Button

First, I used xl2003--I'm not sure the dialogs are the same in xl2007.

Second, you don't assign a function to a commandbutton, you should be able to
just doubleclick on it (while in design mode) and see the commandbutton1_click
event. You should see something like this in the newly opened window:

Option Explicit
Private Sub CommandButton1_Click()

End Sub

Change it to look like:

Option Explicit
Private Sub CommandButton1_Click()
Application.Dialogs(xlDialogGoalSeek).Show
End Sub

Then back to excel, leave design mode and test the commandbutton.

===========
If you really wanted to assign the macro to the button, then you have to use a
button from the Forms toolbar --not the commandbutton from the control toolbox
toolbar.

The code would go into a general module--not the worksheet module.

And would look something like:

Option Explicit
Sub testme()
Application.Dialogs(xlDialogGoalSeek).Show
End Sub


And then you could just rightclick on the button and choose assign macro.


MUEEN SEHDI wrote:

How can I assign a function to a command button placed in Excel 2007 Worksheet?

I need to use Goal Seek command (from Excel Menu/Data/What-If Analysis/Goal
Seek in my worksheet to do some calculation. However instead of following the
menu path, I want to place a button in my worksheet and assign the Goal seek
command to this button. By clicking on this button, the dialogue for Goal
Seek function should appear.


--

Dave Peterson
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do you assign a macro to a command button in Excel 2003 ns Excel Discussion (Misc queries) 5 October 25th 07 08:58 PM
Assign a macro to a command button SheriTingle Excel Discussion (Misc queries) 4 September 25th 06 06:38 PM
Assign a macro to Command Button Object dallin Excel Discussion (Misc queries) 2 July 13th 05 03:50 AM
How to assign a marco to a command button Eric Excel Worksheet Functions 1 May 30th 05 12:44 AM
How do I assign a macro I have created to a Command Button in Exc. Andrew7675 Excel Discussion (Misc queries) 1 March 3rd 05 08:08 PM


All times are GMT +1. The time now is 09:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"