Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Defining a range

Hi, I am using Access to populate a bunch of cells in Excel and then I want
to define a name for these cells...

Here's the business end of my code:

strAddress = "=Story!" & rngStories.Address

'Redefine range in the Order Pad
mxlWbkOrderPad.Names.Add _
Name:="StoryListFill", _
RefersToR1C1:=strAddress

Using the debug window strAddress is:

?strAddress
=Story!A2:C239

The problem is that in the Excel workbook I cannot find the name in the Name
box. However in using the menu Insert name define to display the
define name dialog this is the address for the name!

=Story!'A2':Story!$IE:$IE

If strAddress = "=Story!$A$2:$C$239" then Excel triggers an error: 1004

It seems to me that for some reason Excel has treated A2 as a workbook
reference, maybe?

I can manually define this name directly in Excel using th define name dialog.

Any idea why this is happening and, more importantly, how to have the
correct address for the name?

Any ideas or suggestions appreciated. :-)

Many thanks
Jonathan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Defining a range

With strAddress as "=Story!$A$2:$C$239" try changing
RefersToR1C1:=strAddress to RefersTo:=strAddress
so that a relative reference is not used.

Hope this helps
Rowan


"Jonathan" wrote:

Hi, I am using Access to populate a bunch of cells in Excel and then I want
to define a name for these cells...

Here's the business end of my code:

strAddress = "=Story!" & rngStories.Address

'Redefine range in the Order Pad
mxlWbkOrderPad.Names.Add _
Name:="StoryListFill", _
RefersToR1C1:=strAddress

Using the debug window strAddress is:

?strAddress
=Story!A2:C239

The problem is that in the Excel workbook I cannot find the name in the Name
box. However in using the menu Insert name define to display the
define name dialog this is the address for the name!

=Story!'A2':Story!$IE:$IE

If strAddress = "=Story!$A$2:$C$239" then Excel triggers an error: 1004

It seems to me that for some reason Excel has treated A2 as a workbook
reference, maybe?

I can manually define this name directly in Excel using th define name dialog.

Any idea why this is happening and, more importantly, how to have the
correct address for the name?

Any ideas or suggestions appreciated. :-)

Many thanks
Jonathan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Defining a range

Thanks Rowan

Jonathan

"Rowan Drummond" wrote:

With strAddress as "=Story!$A$2:$C$239" try changing
RefersToR1C1:=strAddress to RefersTo:=strAddress
so that a relative reference is not used.

Hope this helps
Rowan


"Jonathan" wrote:

Hi, I am using Access to populate a bunch of cells in Excel and then I want
to define a name for these cells...

Here's the business end of my code:

strAddress = "=Story!" & rngStories.Address

'Redefine range in the Order Pad
mxlWbkOrderPad.Names.Add _
Name:="StoryListFill", _
RefersToR1C1:=strAddress

Using the debug window strAddress is:

?strAddress
=Story!A2:C239

The problem is that in the Excel workbook I cannot find the name in the Name
box. However in using the menu Insert name define to display the
define name dialog this is the address for the name!

=Story!'A2':Story!$IE:$IE

If strAddress = "=Story!$A$2:$C$239" then Excel triggers an error: 1004

It seems to me that for some reason Excel has treated A2 as a workbook
reference, maybe?

I can manually define this name directly in Excel using th define name dialog.

Any idea why this is happening and, more importantly, how to have the
correct address for the name?

Any ideas or suggestions appreciated. :-)

Many thanks
Jonathan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Defining a range

You're welcome.

"Jonathan" wrote:

Thanks Rowan

Jonathan

"Rowan Drummond" wrote:

With strAddress as "=Story!$A$2:$C$239" try changing
RefersToR1C1:=strAddress to RefersTo:=strAddress
so that a relative reference is not used.

Hope this helps
Rowan


"Jonathan" wrote:

Hi, I am using Access to populate a bunch of cells in Excel and then I want
to define a name for these cells...

Here's the business end of my code:

strAddress = "=Story!" & rngStories.Address

'Redefine range in the Order Pad
mxlWbkOrderPad.Names.Add _
Name:="StoryListFill", _
RefersToR1C1:=strAddress

Using the debug window strAddress is:

?strAddress
=Story!A2:C239

The problem is that in the Excel workbook I cannot find the name in the Name
box. However in using the menu Insert name define to display the
define name dialog this is the address for the name!

=Story!'A2':Story!$IE:$IE

If strAddress = "=Story!$A$2:$C$239" then Excel triggers an error: 1004

It seems to me that for some reason Excel has treated A2 as a workbook
reference, maybe?

I can manually define this name directly in Excel using th define name dialog.

Any idea why this is happening and, more importantly, how to have the
correct address for the name?

Any ideas or suggestions appreciated. :-)

Many thanks
Jonathan

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
Defining Range Name anshu[_2_] Excel Discussion (Misc queries) 2 July 22nd 07 07:30 AM
Defining a range for a look up MH UK Excel Programming 5 February 16th 06 03:11 PM
Help with defining a Range drhalter Excel Programming 2 August 11th 05 11:56 PM
Defining a range Don Excel Worksheet Functions 1 February 25th 05 03:54 PM
Defining a Range Kaval Excel Programming 2 September 5th 04 11:53 PM


All times are GMT +1. The time now is 06:50 AM.

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

About Us

"It's about Microsoft Excel"