How to create a function via VBA?

  • Thread starter Thread starter Melker Sandberg
  • Start date Start date
M

Melker Sandberg

Hi everyone,



I would appreciate some hints on how make a VBA "program" accessible from a
sheet function.



I would like to be able to crate a function in VBA and then be able to use
it as a function in a sheet...something like..... =my.function(A1:B7)



Does someone, have any ideas?



Thank you in advance



Melker
 
For using a function in a sheet you gave the answer yourself.

Piet

Melker Sandberg schreef:
 
I´m sorry but i do not understand.
The idea is that i want to create a new function that does not excist in
Excel and then name it so that i can use it in a sheet as an "ordinary"
function like =sum() or something.

/Melker
 
I´m sorry but i do not understand.
The idea is that i want to create a new function that does not excist in
Excel and then name it so that i can use it in a sheet as an "ordinary"
function like =sum() or something.

/Melker
 
Just as i told you before.

Once you have made the function, let's name him
"Function Test()", you can type in a cel " =Test()" and the function
will execute.

Piet


Melker Sandberg schreef:
 
Aha, now i get it! I´ll try it and see what happens.

Thank you
Melker


"Kweenie" <[email protected]> skrev i meddelandet
Just as i told you before.

Once you have made the function, let's name him
"Function Test()", you can type in a cel " =Test()" and the function
will execute.

Piet


Melker Sandberg schreef:
 
Here's an example how to use it

Copy into a module

Function TestMacro()
MsgBox ActiveWorkbook.Name
End Function

type in A1 =IF(A2=2;Testmacro();"")

type in A2 "2" (Without " ")


Piet


Melker Sandberg schreef:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top