Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calling Function


How can I call a custom function without VBA asking me to assign it to
variable?

Ex:

Sub test()

customFunction(arg1,arg2)

end Sub

is there any way to do this without msgboxing it or assigning it?

Cheer

--
mattsva
-----------------------------------------------------------------------
mattsvai's Profile: http://www.excelforum.com/member.php...fo&userid=3113
View this thread: http://www.excelforum.com/showthread.php?threadid=51181

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Calling Function

Remove "Option Explicit" at the top of the module

The general syntax of a variable declaration is:
Dim VariableName As DataType
If a particular variable is used without first declaring it, or if it
is declared without mentioning a
data type, as in:
Dim Age
then VBA will treat the variable as having type Variant. this is
generally a waste of memory, since variants require more memory than
most other types of
variables.

I always decler variable, then you now wich data type it is.

Regard Yngve

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Calling Function

customFunction(arg1,arg2)

Hi. With your use of ( ), the function is expecting to return a value. Try
it without the use of ( ).

Sub TestIt()
Dim arg1, arg2

CustomFunction arg1, arg2
'or..
Call CustomFunction(arg1, arg2)
End Sub

Function CustomFunction(x, y)
CustomFunction = x * y
End Function

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"mattsvai" wrote in
message ...

How can I call a custom function without VBA asking me to assign it to a
variable?

Ex:

Sub test()

customFunction(arg1,arg2)

end Sub

is there any way to do this without msgboxing it or assigning it?

Cheers


--
mattsvai
------------------------------------------------------------------------
mattsvai's Profile:
http://www.excelforum.com/member.php...o&userid=31134
View this thread: http://www.excelforum.com/showthread...hreadid=511819



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 477
Default Calling Function

I entered the following:

Sub TestIt()
arg1 = Range("b6").Value
arg2 = Range("B10").Value
CustomFunction arg1, arg2
MsgBox "The Answer is " & CustomFunction << But I get Compile error here!!
Why?
End Sub

Function CustomFunction(x, y)
CustomFunction = x * y
End Function





"Dana DeLouis" wrote:

customFunction(arg1,arg2)


Hi. With your use of ( ), the function is expecting to return a value. Try
it without the use of ( ).

Sub TestIt()
Dim arg1, arg2

CustomFunction arg1, arg2
'or..
Call CustomFunction(arg1, arg2)
End Sub

Function CustomFunction(x, y)
CustomFunction = x * y
End Function

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"mattsvai" wrote in
message ...

How can I call a custom function without VBA asking me to assign it to a
variable?

Ex:

Sub test()

customFunction(arg1,arg2)

end Sub

is there any way to do this without msgboxing it or assigning it?

Cheers


--
mattsvai
------------------------------------------------------------------------
mattsvai's Profile:
http://www.excelforum.com/member.php...o&userid=31134
View this thread: http://www.excelforum.com/showthread...hreadid=511819




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Calling Function

Never mind,,, Figured it Out!!
Corrected as follows:

Sub TestIt()
arg1 = Range("b6").Value
arg2 = Range("B10").Value
MyAnswer = CustomFunction(arg1, arg2)
MsgBox "The Answer is " & MyAnswer
End Sub

Function CustomFunction(x, y)
CustomFunction = x * y
End Function


"Jim May" wrote in message
...
I entered the following:

Sub TestIt()
arg1 = Range("b6").Value
arg2 = Range("B10").Value
CustomFunction arg1, arg2
MsgBox "The Answer is " & CustomFunction << But I get Compile error
here!!
Why?
End Sub

Function CustomFunction(x, y)
CustomFunction = x * y
End Function





"Dana DeLouis" wrote:

customFunction(arg1,arg2)


Hi. With your use of ( ), the function is expecting to return a value.
Try
it without the use of ( ).

Sub TestIt()
Dim arg1, arg2

CustomFunction arg1, arg2
'or..
Call CustomFunction(arg1, arg2)
End Sub

Function CustomFunction(x, y)
CustomFunction = x * y
End Function

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"mattsvai" wrote
in
message ...

How can I call a custom function without VBA asking me to assign it to
a
variable?

Ex:

Sub test()

customFunction(arg1,arg2)

end Sub

is there any way to do this without msgboxing it or assigning it?

Cheers


--
mattsvai
------------------------------------------------------------------------
mattsvai's Profile:
http://www.excelforum.com/member.php...o&userid=31134
View this thread:
http://www.excelforum.com/showthread...hreadid=511819








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 function and then returning CLamar Excel Discussion (Misc queries) 4 June 19th 06 06:47 PM
procedure/function calling raja Excel Programming 1 October 3rd 05 12:32 PM
calling a function praptisahni Excel Programming 2 April 26th 04 05:17 PM
Calling VBA function that is in another module Jag Man Excel Programming 2 January 7th 04 03:37 AM


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