![]() |
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 |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 09:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com