Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Call Private Sub From Different Module

Hi,

Is it possible to run a macro from module1, which calls/runs a private sub
in module2.


Thanks
Richard


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Call Private Sub From Different Module

Pretty sure the answer's no - you'd have to make it a public sub

"Richard" wrote:

Hi,

Is it possible to run a macro from module1, which calls/runs a private sub
in module2.


Thanks
Richard


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Call Private Sub From Different Module

Sam

Not the answer I was hoping for, but thanks anyway. Thought I was missing
something really obvious.

Regards
Richard

"Sam Wilson" wrote:

Pretty sure the answer's no - you'd have to make it a public sub

"Richard" wrote:

Hi,

Is it possible to run a macro from module1, which calls/runs a private sub
in module2.


Thanks
Richard


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Call Private Sub From Different Module

Is there a reason you don't want to have a public sub? There may be another
way round the problem.


"Richard" wrote:

Sam

Not the answer I was hoping for, but thanks anyway. Thought I was missing
something really obvious.

Regards
Richard

"Sam Wilson" wrote:

Pretty sure the answer's no - you'd have to make it a public sub

"Richard" wrote:

Hi,

Is it possible to run a macro from module1, which calls/runs a private sub
in module2.


Thanks
Richard


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Call Private Sub From Different Module

Really it's only to keep everything nice and tidy, so that when another user
has to use the workbook and run a macro there is less chance of the wrong
this being run. I can easily keep the macros within the same module, but
this is a little cumbersome when updating code.

"Sam Wilson" wrote:

Is there a reason you don't want to have a public sub? There may be another
way round the problem.


"Richard" wrote:

Sam

Not the answer I was hoping for, but thanks anyway. Thought I was missing
something really obvious.

Regards
Richard

"Sam Wilson" wrote:

Pretty sure the answer's no - you'd have to make it a public sub

"Richard" wrote:

Hi,

Is it possible to run a macro from module1, which calls/runs a private sub
in module2.


Thanks
Richard




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Call Private Sub From Different Module

You could put a dummy parameter in the sub you would rather keep private:

Public Sub test(ByVal dummy As String)

MsgBox "Hello"

End Sub

This won't then be visible to anyone wanting to run a macro from outside the
VBE window, and if you want to call it from another macro you can pass a
dummy parameter:

sub demo

call test("X")

end sub

"Richard" wrote:

Really it's only to keep everything nice and tidy, so that when another user
has to use the workbook and run a macro there is less chance of the wrong
this being run. I can easily keep the macros within the same module, but
this is a little cumbersome when updating code.

"Sam Wilson" wrote:

Is there a reason you don't want to have a public sub? There may be another
way round the problem.


"Richard" wrote:

Sam

Not the answer I was hoping for, but thanks anyway. Thought I was missing
something really obvious.

Regards
Richard

"Sam Wilson" wrote:

Pretty sure the answer's no - you'd have to make it a public sub

"Richard" wrote:

Hi,

Is it possible to run a macro from module1, which calls/runs a private sub
in module2.


Thanks
Richard


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Call Private Sub From Different Module

In module1:
Option Explicit
Sub testme01()
Application.Run "Testme02"
End Sub

In module2:
Option Explicit
Private Sub testme02()
MsgBox "hey, this is private"
End Sub


Richard wrote:

Hi,

Is it possible to run a macro from module1, which calls/runs a private sub
in module2.

Thanks
Richard


--

Dave Peterson
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
Call a Private Sub using a variable Caezar Excel Programming 3 May 4th 08 02:47 PM
Improve method of calling a private function in a private module XP Excel Programming 1 April 30th 08 06:41 PM
How to call a private sub() in another module J@Y Excel Programming 4 July 13th 07 08:08 PM
IF Statements-call private sub CrimsonPlague29 Excel Worksheet Functions 0 May 11th 06 04:54 PM
Call Private Function from ThisWorkbook module Beto[_3_] Excel Programming 3 February 25th 04 01:36 PM


All times are GMT +1. The time now is 12:32 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"