[type in a name] →Insert→Procedure on Function]OK →[Click (the name must be a single word) Place the arguments [defined between the ()] As Type Put after the parenthesis (where is the As type Type variable type of the returned value) Put all other commands between: Function and name()” “Public Function” “End A function subroutine can be used in one of two ways. It can be called by another SUB (or even another function subroutine), or it can be used as a new function in an Excel formula. To make your function available in all future workbooks, save it in your Personal.xlsb library file. Warning: A few math commands are different in VBA than in Excel. In particular: Natural Logarithm of 20 = log(20), not LN(20) Square Root of 20 = sqr(20), not SQRT(20)
→Insert→Procedure [type in a name] →[Click on Function]OK (the name must be a single word) Place the arguments [defined As Type between the ()] Put As Type after the parenthesis (where type is the variable type of the returned value) Put all other commands between: “Public Function name()” and “End Function” A function subroutine can be used in one of two ways. It can be called by another SUB (or even another function subroutine), or it can be used as a new function in an Excel formula. To make your function available in all future workbooks, save it in your Personal.xlsb library file. Warning: A few math commands are different in VBA than in Excel. In particular: Natural Logarithm of 20 = log(20), not LN(20) Square Root of 20 = sqr(20), not SQRT(20)
MgtOp-556-Topic-1-Set-1.docx