Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calling a function in my SQL-DB from VBA | Excel Discussion (Misc queries) | |||
Calling a function and then returning | Excel Discussion (Misc queries) | |||
procedure/function calling | Excel Programming | |||
calling a function | Excel Programming | |||
Calling VBA function that is in another module | Excel Programming |