Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Named Ranges and VBA Add-ins

You have the following code in the Workbook_Open event of which workbook -
the XLA or the workbook where you will use the function.

If the workbook that uses the function, have you tried to see if the name is
returning the values you expect

in a cell
=LondonHolidays


In code
msgbox Typename(Range("LondonHolidays"))

are you getting a date or an error?


--
Regards,
Tom Ogilvy





"Mark" wrote in message
om...
Hello Experts,

I need an answer which I have been unable to find on Usenet or msdn.

Headline1:
As an add-in my program does not seem to be able to reference a named
range.

Problem Summary1:
System: NT4/Excel97
Add-in Name - GBCMCROLIB
Sheet Name - LDN - contains 2 ranges with calendar information

I have the following code in Workbook_Open()

ThisWorkbook.Names.Add Name:="LondonHolidays",
RefersTo:="=[gbcmcrolib.xla]LDN!$B$2:$B$24"
ThisWorkbook.Names.Add Name:="NonReportingFridays",
RefersTo:="=[gbcmcrolib.xla]LDN!$G$2:$G$16"

LondonHolidays is used in the following way in the following code
module

Public Function calFunc01_CalculateLondonBusinessDays( _
startDate As String, endDate As String) As Integer

calFunc01_CalculateLondonBusinessDays = Networkdays(startDate,
endDate, _
Range("LondonHolidays")) - 1

End Function

I have tried to call this function from another macro without success
and have got to the point where I have entered 2 dates in adjacent
cells of the ActiveSheet of a new workbook and am calling the function
from a 3rd cell as follows:

=calFunc01_CalculateLondonBusinessDays(A1,A2)

The result is #VALUE!

Before I changed the ranges from hard-coded to names, everything
worked fine. I started with the file as a .xls file before converting
to a .xla and it worked fine then. What happens to named ranges in an
Add-in? How can I get it to work with names?

Thanks everyone,

Mark



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Named Ranges diaare Excel Worksheet Functions 0 August 24th 07 04:16 PM
Named ranges SheriTingle Excel Discussion (Misc queries) 2 February 14th 07 06:00 PM
Max # of named ranges leaftye - ExcelForums.com Excel Discussion (Misc queries) 1 July 14th 05 07:47 PM
3D Named Ranges David Excel Worksheet Functions 0 June 7th 05 05:22 PM
Like 123, allow named ranges, and print named ranges WP Excel Discussion (Misc queries) 1 April 8th 05 06:07 PM


All times are GMT +1. The time now is 12:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"