Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Calling VBA function that is in another module

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calling VBA function that is in another module

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/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Calling VBA function that is in another module

Colo,
Thanks! I thought I'd tried that, but I now see that it works.

Ed


"Colo " wrote in message
...
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
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
Calling a function in my SQL-DB from VBA KSor Excel Discussion (Misc queries) 0 March 11th 09 02:08 PM
calling a module [email protected] Excel Discussion (Misc queries) 1 September 28th 07 04:03 PM
Calling function from a userform Jeff Excel Discussion (Misc queries) 0 September 27th 06 03:27 PM
Calling a module function from a class method ranafout[_2_] Excel Programming 1 November 12th 03 11:08 AM
Calling Macros oustide current module Mic[_2_] Excel Programming 2 October 28th 03 05:52 PM


All times are GMT +1. The time now is 05:36 PM.

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"