A
agarwaldvk
I have written a custom function (which I eventually want to make as a
AddIn) - one of the argument is a range reference. Seems to work o
when the referred ranges are in any of the open workbooks. But when th
referred workbook is closed, then, it comes up with an error probabl
indicating that it is not able to access the referred range. I can'
understand why. However, all Excel built-in functions, e.g in the SUM(
function are able to do just that.
We know that when the referred range is in a closed w/b, the formul
bar shows the full path of the referred range and the referred value i
read/accessed by the built-in function to give the correct outpu
value. In my case, it doesn't. Can someone help?
The following may help to get to the bottom of the problem tha I a
encountering. Could someone advise me as to what am I supposed to pas
in for the workbook and worksheet reference parameters to access th
referred range in the closed w/b?
I access the range in the closed workbook by using the VBA statement
of the like :-
tempvar
workbooks(referredbooknamewithfullpath).worksheets(referredshee
name).cells(rowref, colref).value
The references to the referred book and sheet names are obtained b
reading the formula as a text string and extracting the relevan
details.
Parts of the codes are shown below :-
This is part of the formula in the formula bar :-
,'D:\Deepak\[Book2.xls]Sheet1'!$B$21:$E$49,
Hence, the value in the variable 'referredbooknamewithpath' i
"D:\Deepak\Book2.xls" and
the value in the variable 'referredsheetname' is "sheet1"
In essence, I am trying to read the value in the cell :-
workbooks("D:\Deepak\Book2.xls").worksheets("sheet1").cells(rowref
colref).value
I even tried to get this parameter values by using the
range.parent.parent.fullname - for full filename and
range.parent.name - for sheet name
Nothing helped.
Further, when the referred range is in a closed w/b, how can you ste
through the custom function code?
Deepak Agarwa
AddIn) - one of the argument is a range reference. Seems to work o
when the referred ranges are in any of the open workbooks. But when th
referred workbook is closed, then, it comes up with an error probabl
indicating that it is not able to access the referred range. I can'
understand why. However, all Excel built-in functions, e.g in the SUM(
function are able to do just that.
We know that when the referred range is in a closed w/b, the formul
bar shows the full path of the referred range and the referred value i
read/accessed by the built-in function to give the correct outpu
value. In my case, it doesn't. Can someone help?
The following may help to get to the bottom of the problem tha I a
encountering. Could someone advise me as to what am I supposed to pas
in for the workbook and worksheet reference parameters to access th
referred range in the closed w/b?
I access the range in the closed workbook by using the VBA statement
of the like :-
tempvar
workbooks(referredbooknamewithfullpath).worksheets(referredshee
name).cells(rowref, colref).value
The references to the referred book and sheet names are obtained b
reading the formula as a text string and extracting the relevan
details.
Parts of the codes are shown below :-
This is part of the formula in the formula bar :-
,'D:\Deepak\[Book2.xls]Sheet1'!$B$21:$E$49,
Hence, the value in the variable 'referredbooknamewithpath' i
"D:\Deepak\Book2.xls" and
the value in the variable 'referredsheetname' is "sheet1"
In essence, I am trying to read the value in the cell :-
workbooks("D:\Deepak\Book2.xls").worksheets("sheet1").cells(rowref
colref).value
I even tried to get this parameter values by using the
range.parent.parent.fullname - for full filename and
range.parent.name - for sheet name
Nothing helped.
Further, when the referred range is in a closed w/b, how can you ste
through the custom function code?
Deepak Agarwa