Referencing a Range from within an Excel Add-in with a UDF

colin42

New Member
Joined
Apr 25, 2011
Messages
2
I have created an excel add-in that contains a series of User Defined functions.

The add-in consists of several worksheets that contain tables and single values, each of these has been referenced by a unique name i.e. "Table1-2" or "Value1-4".

My UDF perform lookup's on these tables. All this wrks great while the workbook is saved in .xlsm format but as soon as i save to .xlam the functions stop working.

How can i refer to ranges that are part of the excel add-in file? I've tried refering directly to the range within the file i.e.

Val1-4 = Range(Workbooks("My Add-in.xlam").Names("Value1-4")).Value

but all i get is
"Run-time error '1004': Method "Range" of object '_Global' Failed

I've also tried

set Tab1-2= range("table1-2") as range

but this doesn't work either.

Please :rolleyes:
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Wouldn't it be more like:

myval = ThisWorkbook.Sheets("whateversheet").Range("Value1_4").Value

... except your names don't look right .... I didn't think that embedded minus signs were valid in defined names or variable names.
 
Upvote 0
Glenn - Thanks that worked.. (y)

so it appears that names that are global in an excel file become local when converted to an add-in.

You're correct about the names - those aren't the names I'm using i just typed them as an example
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top