By using booksticle.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

 


Function

Functions are common in all programming languages. It's a named object that performs a task and returns a value.

It is similar to a subroutine in that it returns a value.

Excel has many functions for example Sum and the VBA function statement allows you to write your own.

An example of a needed function that

if I pass a number to the function I want it to return to me the letter representing the column in Excel.


Naming
What is it?
Returning a value

Real code example ColumnLetter

Passing Parameters

You can think of a function as a black box. This means you don't know how it works, but you give it data and you get an answer.

An example of a function that adds two numbers is:
Function Sum(a,b)
  Sum = a+b
End Function


to call the function you can do something like

z = Sum(7,2)
debug.print z


Lesson



   
Home | About | Videos | Websites | Jobs | FAQ | Privacy | Terms of Service | Edit | Feedback | Copyright © 2024 All Rights Reserved