PC Review


Reply
Thread Tools Rate Thread

Calling VBA function that is in another module

 
 
Jag Man
Guest
Posts: n/a
 
      7th Jan 2004
If I write

Private Function myFunct() As Long
....
End Function

Sub mySub()

I = myFunct()

....

End Sub

everything is OK. However, suppose I wish to put myFunct() in a separate
module. Then
it fails because the compiler can't find it. If myFunct() was in a DLL I
could use Declare
to tell the compiler about it, but that seems to work only for DLLs.

How can I get around this? Or, must all functions used in a module be
defined in it?


TIA

Ed


 
Reply With Quote
 
 
 
 
Colo
Guest
Posts: n/a
 
      7th Jan 2004
Hello Ed

Private Function can be called from the same module, so pls change
Private to Public.
Or you can omit to write "Public", in this case, that UDF would be
treated as a Public Function.
(Note:Public Function should be placed in standard module)


Code:
--------------------

Public Function myFunct() As Long

--------------------



---
Message posted from http://www.ExcelForum.com/

 
Reply With Quote
 
Jag Man
Guest
Posts: n/a
 
      7th Jan 2004
Colo,
Thanks! I thought I'd tried that, but I now see that it works.

Ed


"Colo >" <<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello Ed
>
> Private Function can be called from the same module, so pls change
> Private to Public.
> Or you can omit to write "Public", in this case, that UDF would be
> treated as a Public Function.
> (Note:Public Function should be placed in standard module)
>
>
> Code:
> --------------------
>
> Public Function myFunct() As Long
>
> --------------------
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling Module function in query =?Utf-8?B?SGl0ZXNoIENoYXVoYW4=?= Microsoft Access VBA Modules 4 14th Nov 2007 02:17 PM
Calling a function in another module =?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?= Microsoft Excel Programming 4 7th Nov 2006 03:16 PM
Calling a function (module) from code =?Utf-8?B?RG9yY2k=?= Microsoft Access Form Coding 7 18th May 2006 04:07 AM
calling a module function =?Utf-8?B?SGxld2lz?= Microsoft Access Form Coding 5 23rd Mar 2006 08:33 PM
calling module function from macro =?Utf-8?B?VE1HcmVlbg==?= Microsoft Access Macros 3 8th Mar 2006 12:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:42 PM.