Format for subroutine or function with multiple inputs and multiple outputs - help

spurs

Active Member
Joined
Oct 18, 2006
Messages
479
Office Version
  1. 2016
  2. 2013
  3. 2010
  4. 2007
  5. 2003 or older
Platform
  1. Windows
I am trying to get the syntax right on creating either a subroutine or a function which relys on multiple inputs and can give 2 or more outputs

My function or subroutine should be called Formdata
and has the following inputs coming from the main routine

d
alpha_t
rfbr
df

In my function or subroutine i calculate 2 outputs named
Rf
theta

all values are decimal values

1) should i use a subroutine or function ?
2) What should the syntax look like for the function or subroutine including dim statements if any
3) Does the subroutine or function just simply have a value of Rf and theta calculated or do they need to be named something else?

How do i pull theta and Rf back into the main routine for further use ?

For simplicity the main part of the subroutine or function will simply be
Function Formdata - but i am not sure what follows to differentiate inputs and outputs
Dim d, alpha_t, rfbr, df as variant

Rf=d * sin(alpha_t)
theta =Atn ( rfbr * df)
End function
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
By the way, the actual calculations are much more complicated than what i show and are intertwined so creating 2 separate subroutines or functions is not very memory efficient
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,217
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top