Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function/Sub
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function/Sub
Hi Les,
You can certainly call Subs from Functions, and vice versa. However, if you create a function to be used in a worksheet, then I don't believe you can call a Sub that performs any actions to worksheets. Calling a function from a worksheet only allows you to return a result to the cell calling the function. I believe this to be the case/ Sean. -- (please remember to click yes if replies you receive are helpful to you) "LesHurley" wrote: 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function/Sub
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function/Sub
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function/Sub
OK; I was beginning to realize that: I had some cockpit error when I
reported a #NAME? error. What I really got was a circular reference error which I guess makes sense. Subs can change stuff on the worksheet sao I thought maybe I could do multiple stuff with a function by calling a Sub from the function. Thanks. -- Les "Chip Pearson" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel Data Validation/Lookup function does function correcty | Excel Worksheet Functions | |||
copy of excel file not showing formulal/function in the function b | Excel Discussion (Misc queries) | |||
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) | Excel Worksheet Functions | |||
Excel - User Defined Function Error: This function takes no argume | Excel Programming | |||
Need to open the Function Arguments window from VBA for a user defined function. | Excel Programming |