![]() |
calling VBA functions from a cell
Hi, I've got a function called add(a as int, b as int) that returns a +
b, defined in the correct sheet and workbook I'm currently using. I'd like to be able to call this function from a cell, ie enter in cell A1 the text "=add(4,5)" (without the quote marks) and have it return the answer. I get a NAME? error when I do this. What am I doing wrong? --- Message posted from http://www.ExcelForum.com/ |
calling VBA functions from a cell
Place this code on a normal module sheet.
It can then by used as a normal maths formula Code will need to be modified if a or b is a multiple ranges Function MyFunction(a As Range, b As Range) As Integer MyFunction = a.Value + b.Value End Function --- Message posted from http://www.ExcelForum.com/ |
calling VBA functions from a cell
Put the code in a normal code module, not the ThisWorkbook module
or one of the Sheet modules. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "rturner138 " wrote in message ... Hi, I've got a function called add(a as int, b as int) that returns a + b, defined in the correct sheet and workbook I'm currently using. I'd like to be able to call this function from a cell, ie enter in cell A1 the text "=add(4,5)" (without the quote marks) and have it return the answer. I get a NAME? error when I do this. What am I doing wrong? --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 12:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com