Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 221
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 221
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
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
Private Sub() - Sub() CousinExcel Excel Discussion (Misc queries) 2 January 18th 10 01:39 PM
Private Sub - Hot key? Arturo Excel Programming 1 June 23rd 05 07:17 PM
private sub JT Excel Programming 3 June 3rd 05 10:14 PM
Private Sub Running Other Private Sub Inadvertently Ross Culver Excel Programming 2 February 10th 05 07:17 PM
Private Sub Workbook_Open() not running on open Tim[_39_] Excel Programming 0 August 30th 04 09:11 PM


All times are GMT +1. The time now is 12:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"