Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling functions from dll T.K Kullervo Excel Programming 0 September 29th 03 09:55 AM
Calling certain functions within VBA Myrna Larson[_2_] Excel Programming 0 August 11th 03 10:57 PM
Calling certain functions within VBA Ron de Bruin Excel Programming 0 August 11th 03 10:32 PM
Calling certain functions within VBA james Excel Programming 0 August 11th 03 10:27 PM
Calling VBA functions from a xll Kim[_8_] Excel Programming 2 August 3rd 03 11:48 AM


All times are GMT +1. The time now is 02:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"