Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Call a Function
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Call a Function
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 -- mudraker ------------------------------------------------------------------------ mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473 View this thread: http://www.excelforum.com/showthread...hreadid=522044 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Call a Function
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" <Desert.Piranha.24n3vm_1142306702.1674@excelforu m-nospam.com wrote in message news:Desert.Piranha.24n3vm_1142306702.1674@excelfo rum-nospam.com... 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Call a Function
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 -- 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Is there a do not call function? | Excel Discussion (Misc queries) | |||
Call Sub from Function? | Excel Programming | |||
How do I call this function? | Excel Programming | |||
call a function from VBA | Excel Programming | |||
Function Call | Excel Programming |