PC Review


Reply
Thread Tools Rate Thread

Call a cmdSend_Click macro; non-click interaction

 
 
ryguy7272
Guest
Posts: n/a
 
      10th Dec 2009
I am trying to figure out a way to invoke this macro:

Private Sub cmdSend_Click()
…code
End Sub

As it is now, action is driven by a click event. I am using propriety
software which may require some kind of click event, but I’m not sure about
that. How can I call this macro from another macro, without requiring a user
to interact by clicking the button.

This macro will be called by a worksheet event, which is triggered by a
change in a range of cells on another sheet.

Thanks!
Ryan--


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.
 
Reply With Quote
 
 
 
 
Sam Wilson
Guest
Posts: n/a
 
      10th Dec 2009
Public Sub YourCode()
...code
end sub

then:

Private Sub cmdSend_Click()
Call YourCode
End Sub

and similarly call it from the other worksheet event?

"ryguy7272" wrote:

> I am trying to figure out a way to invoke this macro:
>
> Private Sub cmdSend_Click()
> …code
> End Sub
>
> As it is now, action is driven by a click event. I am using propriety
> software which may require some kind of click event, but I’m not sure about
> that. How can I call this macro from another macro, without requiring a user
> to interact by clicking the button.
>
> This macro will be called by a worksheet event, which is triggered by a
> change in a range of cells on another sheet.
>
> Thanks!
> Ryan--
>
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      10th Dec 2009
And the cmdSend button is on a different sheet?

You know the codename of that sheet that holds that button, right?
Application.Run "'" & ThisWorkbook.Name & "'!sheet1.cmdSend_Click"

Replace sheet1 with the codename for worksheet that owns that commandbutton.

Another way if you know the sheetname, but not its codename:
thisworkbook.Worksheets("Sheetnamehere").cmdSend.Value = True

ryguy7272 wrote:
>
> I am trying to figure out a way to invoke this macro:
>
> Private Sub cmdSend_Click()
> …code
> End Sub
>
> As it is now, action is driven by a click event. I am using propriety
> software which may require some kind of click event, but I’m not sure about
> that. How can I call this macro from another macro, without requiring a user
> to interact by clicking the button.
>
> This macro will be called by a worksheet event, which is triggered by a
> change in a range of cells on another sheet.
>
> Thanks!
> Ryan--
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.


--

Dave Peterson
 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      10th Dec 2009
Thanks Sam! I want to be able to use this code without clicking a button,
which is what I did before. Does this allow me to run something like
button_click() from another macro?

Thanks again!
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Sam Wilson" wrote:

> Public Sub YourCode()
> ...code
> end sub
>
> then:
>
> Private Sub cmdSend_Click()
> Call YourCode
> End Sub
>
> and similarly call it from the other worksheet event?
>
> "ryguy7272" wrote:
>
> > I am trying to figure out a way to invoke this macro:
> >
> > Private Sub cmdSend_Click()
> > …code
> > End Sub
> >
> > As it is now, action is driven by a click event. I am using propriety
> > software which may require some kind of click event, but I’m not sure about
> > that. How can I call this macro from another macro, without requiring a user
> > to interact by clicking the button.
> >
> > This macro will be called by a worksheet event, which is triggered by a
> > change in a range of cells on another sheet.
> >
> > Thanks!
> > Ryan--
> >
> >
> > --
> > Ryan---
> > If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
Sam Wilson
Guest
Posts: n/a
 
      10th Dec 2009
The idea is to take the code that usually runs inside the button_click() sub,
and place it inside a public sub.

Once you've done that, you can change the button_click() sub to call the
new, public, macro, but also call the same macro form wherever you choose.

Sam


"ryguy7272" wrote:

> Thanks Sam! I want to be able to use this code without clicking a button,
> which is what I did before. Does this allow me to run something like
> button_click() from another macro?
>
> Thanks again!
> Ryan--
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.
>
>
> "Sam Wilson" wrote:
>
> > Public Sub YourCode()
> > ...code
> > end sub
> >
> > then:
> >
> > Private Sub cmdSend_Click()
> > Call YourCode
> > End Sub
> >
> > and similarly call it from the other worksheet event?
> >
> > "ryguy7272" wrote:
> >
> > > I am trying to figure out a way to invoke this macro:
> > >
> > > Private Sub cmdSend_Click()
> > > …code
> > > End Sub
> > >
> > > As it is now, action is driven by a click event. I am using propriety
> > > software which may require some kind of click event, but I’m not sure about
> > > that. How can I call this macro from another macro, without requiring a user
> > > to interact by clicking the button.
> > >
> > > This macro will be called by a worksheet event, which is triggered by a
> > > change in a range of cells on another sheet.
> > >
> > > Thanks!
> > > Ryan--
> > >
> > >
> > > --
> > > Ryan---
> > > If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      10th Dec 2009
Wow! Application.Run "'" & ThisWorkbook.Name & "'!sheet1.cmdSend_Click"
That's very clever; never thought of that before.

Thanks, both of you!
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Dave Peterson" wrote:

> And the cmdSend button is on a different sheet?
>
> You know the codename of that sheet that holds that button, right?
> Application.Run "'" & ThisWorkbook.Name & "'!sheet1.cmdSend_Click"
>
> Replace sheet1 with the codename for worksheet that owns that commandbutton.
>
> Another way if you know the sheetname, but not its codename:
> thisworkbook.Worksheets("Sheetnamehere").cmdSend.Value = True
>
> ryguy7272 wrote:
> >
> > I am trying to figure out a way to invoke this macro:
> >
> > Private Sub cmdSend_Click()
> > …code
> > End Sub
> >
> > As it is now, action is driven by a click event. I am using propriety
> > software which may require some kind of click event, but I’m not sure about
> > that. How can I call this macro from another macro, without requiring a user
> > to interact by clicking the button.
> >
> > This macro will be called by a worksheet event, which is triggered by a
> > change in a range of cells on another sheet.
> >
> > Thanks!
> > Ryan--
> >
> > --
> > Ryan---
> > If this information was helpful, please indicate this by clicking ''Yes''.

>
> --
>
> Dave Peterson
> .
>

 
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
Call Macro using right click menu =?Utf-8?B?SXZhbg==?= Microsoft Excel Programming 3 4th May 2006 02:29 AM
How to call a sub defined in macro when double click a cell? =?Utf-8?B?SXZhbg==?= Microsoft Excel Programming 3 20th Nov 2005 09:46 PM
Call Userfor and click button with macro ExcelMonkey Microsoft Excel Programming 2 25th Feb 2005 04:41 PM
Call macro from click on shape (COM add-in) DannyAndersen Microsoft Excel Programming 0 21st Mar 2004 08:50 PM
voice call ivr interaction Peter Belbin Windows XP Messenger 0 8th Sep 2003 06:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:58 PM.