I am a newbie to excel VBA programming but I must admit its a very powerful tool. Irony it , I realized it after 20 years of using excel

Query - I am creating a function like below -

MVAR1,MVAR2,MVAR3 and MVAR4 are math variables. How I need to interpret these variables will be defined via. the string variable Whattodo.

If Whattodo = MVAR1 + MVAR2 + MVAR3 + MVAR4 ----- Function shall return the sum of all 4 variables.
If Whattodo = (MVAR1 + MVAR2 + MVAR3 + MVAR4)/4 ----- Function shall return the average all 4 variables.

There is no limit to the combinations of "Whattodo".............

How can i achieve this ????? Thanks in advance.

Function Correctanswer(MVAR1 As Long, MVAR2 As Long, MVAR3 As Long, MVAR4 As Long, Whattodo As String) As Long




Correctanswer = DO whatver is stored in Whatotdo


End Function