Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
running private sub
there has to be a simple answer. i see all these references to private sub,
how do you run the code? private sub worksheet_test(this is a test) code here end sub i have no idea how to call this, can someone explain? thanks -- Gary |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
running private sub
Private subs are run on the event. For instance, Private Sub
Worksheet_Activate() will run when the worksheet is activated. Private Sub Workbook_Open() runs when the workbook is open. You can find all events like this by going into the Visual Basic Editor and getting the code window at right. Hit the dropdown and choose Workbook, then choose the right-hand dropdown and choose one of the events. Then double-click one of the sheet tabs, and do the same. You'll see all the different events there, and it auto-creates the macro names for you so you can tell what they are. Hope this helps! ******************* ~Anne Troy www.OfficeArticles.com "Gary Keramidas" wrote in message ... there has to be a simple answer. i see all these references to private sub, how do you run the code? private sub worksheet_test(this is a test) code here end sub i have no idea how to call this, can someone explain? thanks -- Gary |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
running private sub
ok, i think i have it now.
thanks -- Gary "Anne Troy" wrote in message news:959d5$42d368c6$97c5108d$28551@allthenewsgroup s.com... Private subs are run on the event. For instance, Private Sub Worksheet_Activate() will run when the worksheet is activated. Private Sub Workbook_Open() runs when the workbook is open. You can find all events like this by going into the Visual Basic Editor and getting the code window at right. Hit the dropdown and choose Workbook, then choose the right-hand dropdown and choose one of the events. Then double-click one of the sheet tabs, and do the same. You'll see all the different events there, and it auto-creates the macro names for you so you can tell what they are. Hope this helps! ******************* ~Anne Troy www.OfficeArticles.com "Gary Keramidas" wrote in message ... there has to be a simple answer. i see all these references to private sub, how do you run the code? private sub worksheet_test(this is a test) code here end sub i have no idea how to call this, can someone explain? thanks -- Gary |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
running private sub
Also, Private subs don't show under Tools--Macro--Macros, so you can use
them to run subs from other subs that aren't private, you know? ******************* ~Anne Troy www.OfficeArticles.com "Gary Keramidas" wrote in message ... ok, i think i have it now. thanks -- Gary "Anne Troy" wrote in message news:959d5$42d368c6$97c5108d$28551@allthenewsgroup s.com... Private subs are run on the event. For instance, Private Sub Worksheet_Activate() will run when the worksheet is activated. Private Sub Workbook_Open() runs when the workbook is open. You can find all events like this by going into the Visual Basic Editor and getting the code window at right. Hit the dropdown and choose Workbook, then choose the right-hand dropdown and choose one of the events. Then double-click one of the sheet tabs, and do the same. You'll see all the different events there, and it auto-creates the macro names for you so you can tell what they are. Hope this helps! ******************* ~Anne Troy www.OfficeArticles.com "Gary Keramidas" wrote in message ... there has to be a simple answer. i see all these references to private sub, how do you run the code? private sub worksheet_test(this is a test) code here end sub i have no idea how to call this, can someone explain? thanks -- Gary |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
running private sub
Private subs are subs that you only want to be allowed to be called from the
module that they are contained within. So, any private subs in module1 cannot be accessed from module2 say, even in the same workbook. By default, worksheet and workbook events are declared private, so they too could not be called from another module. However, you can change them to public with no problem, but if you do call them from another module, you need to precede the macro by its sheet name, as a worksheet code module is an instance of a class. Private subs do not show in the list of macros under ToolsMacro, but neither do subs that have arguments. -- HTH RP (remove nothere from the email address if mailing direct) "Gary Keramidas" wrote in message ... there has to be a simple answer. i see all these references to private sub, how do you run the code? private sub worksheet_test(this is a test) code here end sub i have no idea how to call this, can someone explain? thanks -- Gary |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Private Sub() - Sub() | Excel Discussion (Misc queries) | |||
Private Sub - Hot key? | Excel Programming | |||
private sub | Excel Programming | |||
Private Sub Running Other Private Sub Inadvertently | Excel Programming | |||
Private Sub Workbook_Open() not running on open | Excel Programming |