Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calling Private Sub/Function


So how can you call a Private Sub or Function? Or is that simply not
possible? I have an OnTime event that needs to call another Sub when
the timer runs out, but that other Sub is private.


--
AMK4
------------------------------------------------------------------------
AMK4's Profile: http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=508329

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Calling Private Sub/Function

Hi AMK4

Look at the Run method in VBA help.


---
Regards,
Norman



"AMK4" wrote in message
...

So how can you call a Private Sub or Function? Or is that simply not
possible? I have an OnTime event that needs to call another Sub when
the timer runs out, but that other Sub is private.


--
AMK4
------------------------------------------------------------------------
AMK4's Profile:
http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=508329



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calling Private Sub/Function


Norman Jones Wrote:
Hi AMK4

Look at the Run method in VBA help.


I'm a bit confused. How would I use this in an OnTime method?

This is what I'm trying to get to:

My userForm has this on it:
Application.OnTime Now + TimeValue("00:00:05"), "myMacro"

myMacro is a Private Sub defined in the Modules. How would I use
Application.Run instead of calling myMacro?


--
AMK4
------------------------------------------------------------------------
AMK4's Profile: http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=508329

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Calling Private Sub/Function

Hi AMK4,

One way:

Sub AAA()
Application.OnTime Now + TimeValue("00:00:05"), "myMacro"
End Sub

Sub myMacro()
Call BBB
End Sub

Private Sub BBB()
MsgBox "Hello"
End Sub


---
Regards,
Norman



"AMK4" wrote in message
...

Norman Jones Wrote:
Hi AMK4

Look at the Run method in VBA help.


I'm a bit confused. How would I use this in an OnTime method?

This is what I'm trying to get to:

My userForm has this on it:
Application.OnTime Now + TimeValue("00:00:05"), "myMacro"

myMacro is a Private Sub defined in the Modules. How would I use
Application.Run instead of calling myMacro?


--
AMK4
------------------------------------------------------------------------
AMK4's Profile:
http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=508329



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Calling Private Sub/Function

Hi AMK4,

In fact, if no parameters are to be passed, the private macro or function
can be called without recourse to the Run method:

Sub AAA()
Application.OnTime Now + TimeValue("00:00:05"),"MyMacro"
End Sub

Or, if the macro is in another workbook:

Sub AAAA()
Application.OnTime Now + TimeValue("00:00:05"), _
"'Another Workbook'!MyMacro"
End Sub

Or, if the macro is in a sheet module of another workbook:

Sub AAAAA()
Application.OnTime Now + TimeValue("00:00:05"), _
"'Another Workbook'!Sheet1.MyMacro"
End Sub


---
Regards,
Norman


"AMK4" wrote in message
...

Norman Jones Wrote:
Hi AMK4

Look at the Run method in VBA help.


I'm a bit confused. How would I use this in an OnTime method?

This is what I'm trying to get to:

My userForm has this on it:
Application.OnTime Now + TimeValue("00:00:05"), "myMacro"

myMacro is a Private Sub defined in the Modules. How would I use
Application.Run instead of calling myMacro?


--
AMK4
------------------------------------------------------------------------
AMK4's Profile:
http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=508329





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Calling Private Sub/Function

Hi AMK4,

And, if parameters are to be passed to the function or macro, then try
something like:

Sub ABC()
Application.OnTime Now + TimeValue("00:00:05"), "BBB"
End Sub

Sub BBB()
MsgBox Application.Run("MyFunction", 2, 3)
End Sub

Private Function MyFunction(var1, var2)
MyFunction = var1 * var2
End Function


---
Regards,
Norman


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
difference between a private sub and a public function? Dave F Excel Discussion (Misc queries) 4 March 16th 07 07:38 PM
private variable: same module, other Sub/Function Stefi Excel Programming 4 July 5th 05 09:10 AM
Calling a Private Sub ben Excel Programming 8 December 8th 04 10:18 PM
Calling a private sub Bob Phillips[_7_] Excel Programming 3 July 29th 04 02:59 AM
calling private subs dunlklee Excel Programming 1 December 16th 03 08:40 AM


All times are GMT +1. The time now is 10:04 AM.

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"