Hi all,
I can call a Macro like
'Call TestCode
or
'Run TestCode
or
TestCode
or use Select Case
etc
If i have a function named TestCode why can i not call it in this way?
Hi all,
I can call a Macro like
'Call TestCode
or
'Run TestCode
or
TestCode
or use Select Case
etc
If i have a function named TestCode why can i not call it in this way?
Thx
Dave
"The game is afoot Watson"
Desert
You can call the function the same way unless you are expecting the function to return data back to your macro or if you are passing variable data onto the function
Sub Macro1()
call Function1
End Sub
Function MyFunction1()
function code here
End Function
or
Sub Macro2()
dim MyVariable As String
MyVariable = MyFunction2
End Sub
Function MyFunction2() as String
MyFunction2 = "Hi"
End Function
or
Sub Macro3()
dim MyVariable As Integer
MyVariable = MyFunction3(4)
End Sub
Function MyFunction3(iVariable As Integer) as Integer
MyFunction3 = iVariable + 6
End Function
or
If the function is on a worksheet module then you will need to use the full sheet name as well as the function name
eg
call Sheet1.Function1
Hi Dave,
> If i have a function named TestCode why can i not call it in this way?
You can. However, if the function returns a value, you may not observe any
response.
For demonstaryion purposes, I include a msgbox in the function:
Try:
'=============>>
Public Function ABC(aVal As Double)
ABC = aVal * 2
MsgBox ABC
End Function
'<<=============
'=============>>
Sub TestIt()
ABC (5)
Call ABC(100)
End Sub
'<<=============
---
Regards,
Norman
"Desert Piranha"
<[email protected]> wrote in
message news:[email protected]...
>
> Hi all,
>
> I can call a Macro like
>
> 'Call TestCode
> or
> 'Run TestCode
> or
> TestCode
> or use Select Case
> etc
>
> If i have a function named TestCode why can i not call it in this way?
>
>
> --
> Desert Piranha
>
>
> ------------------------------------------------------------------------
> Desert Piranha's Profile:
> http://www.excelforum.com/member.php...o&userid=28934
> View this thread: http://www.excelforum.com/showthread...hreadid=522044
>
Hi Mudraker & Norman,
Thank You both for contributing to this.
This is over my head. Im quiting on this for now, as i can't seem to work with it.
Its for personal use, and i have some stuff to do for work.
I will keep your stuff for future.
Thx again Norman and Mudraker
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks