How to create a simple VBA Custom Function
Through Insert | Name | Define, I can create a name (for example €śMyRatio€ť)
to hold the value 2.53. In VBA, how can I create a function to hold this value? I know nothing about creating Custom VBA Function and is trying to learn from this simple example. Lets give the function the name €śMyRatio€ť and I need it to hold any value with 2 decimals. Its ok to hardcode the value within the function procedure as I will edit the value in VBA whenver the rate changes. Any help is appreciated. Thanks a lot -- Edmund (Using Excel XP) |
How to create a simple VBA Custom Function
In your visual basic editor, right click on your project in the project pane and select Insert - Module. Write your function code in this new module. -- C01d ------------------------------------------------------------------------ C01d's Profile: http://www.excelforum.com/member.php...o&userid=34422 View this thread: http://www.excelforum.com/showthread...hreadid=544145 |
How to create a simple VBA Custom Function
What is the difference if I insert my Function in a Module, class Module and just a spreadsheet (e.g. Sheet1) -- tmingfai ------------------------------------------------------------------------ tmingfai's Profile: http://www.excelforum.com/member.php...o&userid=34221 View this thread: http://www.excelforum.com/showthread...hreadid=544145 |
How to create a simple VBA Custom Function
tmingfai,
You can not define a Function in a cell or range of a spreadsheet. I think you can define it in a Class Module, but I've never done that. In a nutshell, the difference between a Macro and a Function is that macros perform actions while Functions return a value. Functions don't *do* anything. "tmingfai" wrote: What is the difference if I insert my Function in a Module, class Module and just a spreadsheet (e.g. Sheet1) -- tmingfai ------------------------------------------------------------------------ tmingfai's Profile: http://www.excelforum.com/member.php...o&userid=34221 View this thread: http://www.excelforum.com/showthread...hreadid=544145 |
How to create a simple VBA Custom Function
If you're intending to call function macros from a spreadsheet, you
should put them in a standard module. |
How to create a simple VBA Custom Function
:I think
you can define it in a Class Module, but I've never done that. You can't do that. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "cush" wrote in message ... tmingfai, You can not define a Function in a cell or range of a spreadsheet. I think you can define it in a Class Module, but I've never done that. In a nutshell, the difference between a Macro and a Function is that macros perform actions while Functions return a value. Functions don't *do* anything. "tmingfai" wrote: What is the difference if I insert my Function in a Module, class Module and just a spreadsheet (e.g. Sheet1) -- tmingfai ------------------------------------------------------------------------ tmingfai's Profile: http://www.excelforum.com/member.php...o&userid=34221 View this thread: http://www.excelforum.com/showthread...hreadid=544145 |
All times are GMT +1. The time now is 04:25 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com