Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / March 2005

Tip: Looking for answers? Try searching our database.

Macro on cell content

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Riko Wichmann - 01 Mar 2005 16:19 GMT
Dear all,

this must be a common problem, and I thought I found the solution, but
it doesn't work ... I'm probably missing something very simple.

I want to execute a simple VB function in one cell, taking another cell
as Parameter. Both, parameter cell and function result are strings. For
example:

A1: "this is content of cell A1"
A2: =Convert(A1)

and Convert is a VB function

Function Convert(content As string) as String

    ' do something depending on content
    Convert = "result-string"
End Function

However, I always get a #NAME? Error in cell A2.

The idea is of course, that I don't want to explicitly execute a macro
by hand, but have something similar to A2 = A1*2, just for a function all.

How do I do this kind of exercise properly?

Thanks a lot,

    Riko
JE McGimpsey - 01 Mar 2005 17:52 GMT
You probably put the function in the worksheet or workbook code module.
Functions should normally go into regular code modules (choose
Insert/Module in the Visual Basic Editor).

If you want to leave the function in the worksheet code module, you'll
need to qualify the function call:

   =Sheet1.CONVERT(A1)

Note that Convert is also the name of a function in the Analysis Toolpak
Add-in.

> Dear all,
>
[quoted text clipped - 26 lines]
>
>     Riko
Riko Wichmann - 03 Mar 2005 14:07 GMT
Aha, it seems like the problem was buried in the fact, that I had named
the module the same as the function.
After renaming the module, the function was excecuted just fine ... took
me some time to figure that out, though!

    Cheers,

        Riko

> You probably put the function in the worksheet or workbook code module.
> Functions should normally go into regular code modules (choose
[quoted text clipped - 38 lines]
>>
>>    Riko
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.