vba - Excel Function - Dynamic file link -


i'm trying create excel function (udf) there gets data closed excel file, based on file name in cell.

i have working in macro, can't function work.

the macro - there working looks this:

sub testgetdata()     dim wbpath string     dim wbname string     dim wsname string     dim cellref string     dim ret string      ' test data     wbpath = "c:\users\tue\desktop\mgh\"     wbname = "rentabilitet 30.xls"     wsname = "rentabilitet"     cellref = "f15"      ret = "'" & wbpath & "[" & wbname & "]" & wsname & "'!" & range(cellref).address(true, true, -4150)      msgbox executeexcel4macro(ret) end sub 

i have created function based on macro, not working. this:

function samplefunc(wbpath string, wbname string, wsname string, cellref string)     dim ret string     ret = "'" & wbpath & "[" & wbname & "]" & wsname & "'!" & range(cellref).address(true, true, -4150)     samplefunc = application.executeexcel4macro(ret) end function 

is executeexcel4macro there can work in function? or?

/tue


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -