Thread: Function/Sub
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Function/Sub

A Function or Sub called from a worksheet cell, directly or indirectly,
cannot modify any part of the Excel environment, including changing the
contents of any cell, including the cell from which it was called. I'm
surprised that you get a #NAME error. I would have expected that you would
get a #VALUE error.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"LesHurley" wrote in message
...
well maybe Sean answered it. Suppose I have:

Sub Good()
Selection.Value="Good"
End Sub

Function OK()
Good
End Function

The Sub procedure works OK, it returns "Good" to the selected cell in the
worksheet by clicking tools/macros/good, but typing =OK() gives a #NAME
error.--


"Bob Phillips" wrote:

In VBA yes. A function can call a sub and vice versa.

What makes you think that it might not?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"LesHurley" wrote in message
...
Is it possible to make a VBA Function call a Sub ? I don't have any
problem
calling either from one of the same kind.--
Thanks for your help