PC Review


Reply
Thread Tools Rate Thread

how do i make a commandbutton run a macro??

 
 
=?Utf-8?B?U2hheA==?=
Guest
Posts: n/a
 
      6th Jun 2006
I have this project i have to do for work and i want the commandbuttons to
open seperate sheets within the workbook - but i dont understand all this
visual basic language stuff so can someone please translate it into a dummy
version for me - i can run a macro by recording it but how do i make the
macro perform within the button??? i remember doing it in college but can not
rem think it was an older version - all help is appreciated.

thank you for ur time and many regards



 
Reply With Quote
 
 
 
 
=?Utf-8?B?Uko=?=
Guest
Posts: n/a
 
      6th Jun 2006
There are a couple easy ways to do this. I guess the easiest would be to
right click on the command button and go to view code and insert the
following code.

Private Sub CommandButton1_Click()
Application.Run "YourWorkbookName!YourMacroName"
End Sub

Where YourWorkbookName will be the name of the workbook you are workign in
and the YourMacroName will be the name of the Macro you want the
commandbutton to open.

"Shax" wrote:

> I have this project i have to do for work and i want the commandbuttons to
> open seperate sheets within the workbook - but i dont understand all this
> visual basic language stuff so can someone please translate it into a dummy
> version for me - i can run a macro by recording it but how do i make the
> macro perform within the button??? i remember doing it in college but can not
> rem think it was an older version - all help is appreciated.
>
> thank you for ur time and many regards
>
>
>

 
Reply With Quote
 
=?Utf-8?B?U2hheA==?=
Guest
Posts: n/a
 
      6th Jun 2006
tried that RJ and it says - run time error '1004' and that it failed - any
idea wot im doing wrong????
can u give me an example of wot the workbook name cud be?? its a case of -
the actual file name and the sheets from 1 to 9 all i need is to be able to
click the buttons to go to the relevant pages??



 
Reply With Quote
 
=?Utf-8?B?U2hheA==?=
Guest
Posts: n/a
 
      6th Jun 2006
Private Sub CommandButton1_Click()
Application.Run "smart_pack!PERSONAL.XLS!Macro3"
End Sub

is this rite?? this is the command i put in?? smartpack the file name and
the macro??
i appreciate any help as is getting late and i want to make one of the
buttons to work before i go to bed to get my beauty sleep - lol?? (trust me i
need it!!!!)



 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      6th Jun 2006
Probably due to an error in the macro syntax. Post you coding efforts here
by copy/paste. I suggest using a button from the forms toolbar or a shape
from a the drawing toolbar instead of a command button.

--
Don Guillett
SalesAid Software
(E-Mail Removed)
"Shax" <(E-Mail Removed)> wrote in message
news:67DCF4D8-1D22-403B-8257-(E-Mail Removed)...
> tried that RJ and it says - run time error '1004' and that it failed -
> any
> idea wot im doing wrong????
> can u give me an example of wot the workbook name cud be?? its a case of -
> the actual file name and the sheets from 1 to 9 all i need is to be able
> to
> click the buttons to go to the relevant pages??
>
>
>



 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      6th Jun 2006
personal.xls is the file where your macro probably is
try
Application.Run "PERSONAL.XLS!macro3"

--
Don Guillett
SalesAid Software
(E-Mail Removed)
"Shax" <(E-Mail Removed)> wrote in message
news:4A4908AC-125D-4571-BDC2-(E-Mail Removed)...
> Private Sub CommandButton1_Click()
> Application.Run "smart_pack!PERSONAL.XLS!Macro3"
> End Sub
>
> is this rite?? this is the command i put in?? smartpack the file name and
> the macro??
> i appreciate any help as is getting late and i want to make one of the
> buttons to work before i go to bed to get my beauty sleep - lol?? (trust
> me i
> need it!!!!)
>
>
>



 
Reply With Quote
 
=?Utf-8?B?Uko=?=
Guest
Posts: n/a
 
      7th Jun 2006
Your workbook name is Personal.xls and your macro name is Macro3. Your code
should look like this.

Private Sub CommandButton1_Click()
Application.Run "PERSONAL.XLS!Macro3"
End Sub


"Shax" wrote:

> Private Sub CommandButton1_Click()
> Application.Run "smart_pack!PERSONAL.XLS!Macro3"
> End Sub
>
> is this rite?? this is the command i put in?? smartpack the file name and
> the macro??
> i appreciate any help as is getting late and i want to make one of the
> buttons to work before i go to bed to get my beauty sleep - lol?? (trust me i
> need it!!!!)
>
>
>

 
Reply With Quote
 
=?Utf-8?B?U2hheA==?=
Guest
Posts: n/a
 
      7th Jun 2006
think im gonna cry .................. it workedddd thankyou RJ and DON i
absolutely appreciate your help

take care

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Make CommandButton on Menu Bar Minitman Microsoft Excel Programming 2 7th May 2007 04:15 PM
How do I make a commandbutton in Excel 'launch' a custom form? =?Utf-8?B?Y2hvcmlzbW9z?= Microsoft Excel Programming 2 12th Oct 2006 04:12 PM
how do you make a commandbutton run a macro? =?Utf-8?B?U2hheA==?= Microsoft Access Macros 2 6th Jun 2006 09:17 PM
HOW TO MAKE A QUERY WORK IN ONCLICK EVENT OF A COMMANDBUTTON shreeja Microsoft Access Forms 0 6th Jul 2004 05:06 AM
Macro won't run from CommandButton Nathan Gutman Microsoft Excel Programming 3 24th Dec 2003 07:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:44 AM.