Just wonder how to call the function if I have it's name in the variable String
for example something like that:
Please Login or Register to view this content.
maybe there are some other ways?
Thank you for your help,
arbus
Just wonder how to call the function if I have it's name in the variable String
for example something like that:
Please Login or Register to view this content.
maybe there are some other ways?
Thank you for your help,
arbus
Last edited by arbus; 08-30-2007 at 09:56 AM.
I completed your example to illustrate it better:
Please Login or Register to view this content.
Best regards,
Ray
hi rayOriginally Posted by raypayette
I am not sure that I understood you
I used CallByName fucntion because there is such a fuction which executes a method of an object
So I thought maybe it can be used for calling a function if u have its name saved in the string variable
in my example I know that there is a function named "test" and I wanted to call that function
Imagine u have a list of similar finctions: test1, test2, test3 etc
you want to call them in the loop
so inside the loop u will assign a string variable name="test"+cstr(i) and afterfards u want to call the function with name="test"+cstr(i)
Last edited by arbus; 08-30-2007 at 09:59 AM.
I tried to work out the glitches. For example result = "test" will not use the function test, rather it defines it as the string test; I correct3ed it to use the Boolean function "test". Also you redefined name as a text when it was a Boolean value; I corrected it.
any ideas?
Hi
Try this. In C1 enter the value xxx.
Then run
The first result will be xxx which is the value in C1. The second answer will be $C$1 which is the address of C1.Please Login or Register to view this content.
So unless your object has a method of test, then you cannot use this to call it.
Does that help to make things clearer???
rylo
Maybe you mean
Or in the worksheetPlease Login or Register to view this content.
=test()
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
thats a brilliant idea, thanks!
what I wanted - to be able in the loop to generate string variables with function names (functions in the module already exist)
and afterwards to be able to call those functions (by their name stored in the string var) in the other module
imagine - I have a list of test functions named test1(), test2() etc
and I dont want to run all of them all the time
there is a config txt file with names of the function to be run
when macro is started it reads that file and has the list of names of the functions which I want to execute one by one
so the problem now is to run the existing function with a specified name
_________
the only solution found (thanks to rylo and royUK) (maybe not very elegant but perfectly working) is to use a temporary cell and print in it "=test1()" (if function name is "test1")
and to get the result of the function from that cell aftewards
so far I dont see how it can be done inside vbe only without using excell cells as a temporary storage of the result
Last edited by arbus; 08-31-2007 at 07:45 AM.
Your example Function will be available whilst that workbook is open, because you actually set it to True. What is an example of a Function you ant to use?
I didnt get ur question
maybe the following code will help to understand the problem
I would like not to use cells for storing the result but even as it is now - it works
Please Login or Register to view this content.
Hi
OK, same sort of thing as your example, but you don't have to use a cell to get the results
HTHPlease Login or Register to view this content.
rylo
cool!
thanks rylo
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks