Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default in vb, what is the 1-line code of assigning a macro using click

I am looking for a sample of the syntax where the macro name and click are on
the vb line.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default in vb, what is the 1-line code of assigning a macro using click

For a control from the forms toolbar:

Activesheet.Buttons(1).OnAction = "MyMacro"

--
Regards,
Tom Ogilvy


"ExcelSuperUser" wrote:

I am looking for a sample of the syntax where the macro name and click are on
the vb line.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default in vb, what is the 1-line code of assigning a macro using clic

sorry, not what i was looking for. let me give you more info. i set up a
command button in excel and would like to assign the macro to the button. if
i right click, assign macro is not listed (not sure why) but if i go to the
vb editor, i would like to type a line in that assigns the macro to the
button. i seem to recall that it would have the button object, macro name
and click on one line. i also recall that it is very simple and a basic
statement.

"Tom Ogilvy" wrote:

For a control from the forms toolbar:

Activesheet.Buttons(1).OnAction = "MyMacro"

--
Regards,
Tom Ogilvy


"ExcelSuperUser" wrote:

I am looking for a sample of the syntax where the macro name and click are on
the vb line.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default in vb, what is the 1-line code of assigning a macro using clic

I gave you the code to assign a macro to a button from the forms toolbar.
However, Command buttons from the control toolbox toolbar are not assigned to
macros. They have build in events. To get to the Click event for the
Commandbutton, right click on the sheet tab that contains the button and
select view code. In the resulting sheet module, at the top of the module,
in the left dropdown select Commandbutton1 (or the name of your command
button) and in the right dropdown select Click.

YOu will get the event

Private Sub CommandButton1_Click()

End sub

You can put your code in this procedure/event. (including a call to a macro
in a general module).

--
regards,
Tom Ogilvy


"ExcelSuperUser" wrote:

sorry, not what i was looking for. let me give you more info. i set up a
command button in excel and would like to assign the macro to the button. if
i right click, assign macro is not listed (not sure why) but if i go to the
vb editor, i would like to type a line in that assigns the macro to the
button. i seem to recall that it would have the button object, macro name
and click on one line. i also recall that it is very simple and a basic
statement.

"Tom Ogilvy" wrote:

For a control from the forms toolbar:

Activesheet.Buttons(1).OnAction = "MyMacro"

--
Regards,
Tom Ogilvy


"ExcelSuperUser" wrote:

I am looking for a sample of the syntax where the macro name and click are on
the vb line.

Reply
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
Macro code to put series name next to individual line in line grap Otani Charts and Charting in Excel 3 February 23rd 10 07:24 PM
Assigning Macro by using code Bob Phillips Excel Programming 1 January 9th 07 07:31 PM
macro code for grouping adjacent cells into one multi-line cel M John Excel Programming 0 November 29th 05 11:54 PM
Using a macro to code a checkbox on click - Help Rog[_3_] Excel Programming 1 October 25th 04 07:16 PM
Assigning click event to OleObjects checkbox Jim McLeod Excel Programming 5 April 20th 04 07:02 PM


All times are GMT +1. The time now is 11:10 PM.

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

About Us

"It's about Microsoft Excel"