3D Ranges

G

Guest

I am looking for a very simple piece of code illustrating the format for a
"3D" range ie one that spans more than one worksheet. Can anyone help. the MS
help function is utterly useless. Thanks
 
G

Guest

I was wanting to name a range in multiple worksheets and refer to the named
range
 
H

Harlan Grove

Vasant Nanavati wrote...
If I understand you correctly, you can't name a 3D range in Excel.
....

No?

I open a new workbook, enter {1,2;6,3;5,4} in Sheet1!A1:B3 and
{100,200;600,300;500,400} in Sheet2!A1:B3, create the defined name x
referring to Sheet1:Sheet2!$A$1:$B$3, and enter the following formula
in Sheet1!D1.

=SUM(x)

This formula returns 2121, as expected.
 
V

Vasant Nanavati

Hi Harlan:

It doesn't work for me (Excel 2002); what am I doing wrong?

Regards,

Vasant
 
V

Vasant Nanavati

Further, Names("x") does not have a RefersToRange property, only a RefersTo
property.
 
T

Tushar Mehta

Hi Vasant,

The easiest way is to let XL do the work. Rather than typing the
range, I used the mouse to select the 2 sheets then the range. XL put
a single quote around the sheet1:sheet2 part.

I suspect 3D ranges are a kludge that MS cobbled together in response
to what it must have perceived as a competitive threat from one of the
other spreadsheet packages. It's a kludge since a 3D range violates
the XL object model. A range's parent is a worksheet. But, that,
obviously, is not true for a 3D range. So, it kinda works where it
works. I cannot recall MS making any enhancements to the 3D capability
since it was first introduced, which shouldn't really be a surprise
since it would require redoing a core component of the OM.

Further, it should not come as a surprise that it doesn't play well
with VBA. For example, with a single-sheet named range, the following
works just fine:
?application.worksheetfunction.Sum(range(activeworkbook.Names(2).Name))

But, replace Names(2) with Names(1) and the result is 'Application-
defined or object-defined error.' Yes, Names(1) is the 3D range and
Names(2) is a single-sheet name.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
T

Tushar Mehta

If you mean VBA code, turn on the macro recorder (Tools | Macro >
record new macro...) do whatever it is you want through the GUI, turn
off the recorder, and switch to the VBE. In most cases, XL will give
you the necessary code.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
H

Harlan Grove

Tushar Mehta said:
I suspect 3D ranges are a kludge that MS cobbled together in response
to what it must have perceived as a competitive threat from one of the
other spreadsheet packages. It's a kludge since a 3D range violates
the XL object model. A range's parent is a worksheet. But, that,
obviously, is not true for a 3D range. So, it kinda works where it
works. I cannot recall MS making any enhancements to the 3D capability
since it was first introduced, which shouldn't really be a surprise
since it would require redoing a core component of the OM.
....

They're kludges, but they aren't ranges. IIRC, they debuted in Excel 4, and
they're not much more than syntactic sugar providing formula means to
accomplish Data > consolidate across worksheets.

Online help is careful to refer to them only as 3D *REFERENCES*, not ranges,
and they don't function at all in VBA or the Excel object model, so nothing
violated.

There's nothing magic about making worksheets the parent class of the range
class. The workbook class could just as easily be the parent for the range
class (as is the case in Lotus 123's 32-bit object model). It would require
a thorough rewrite to change this, but Excel desperately needs such a
rewrite.
 
V

Vasant Nanavati

Harlan Grove said:
They're kludges, but they aren't ranges. IIRC, they debuted in Excel 4, and
they're not much more than syntactic sugar providing formula means to
accomplish Data > consolidate across worksheets.

I guess that's what I was trying to convey when I said you couldn't name a
3D range. The solution you provided seems more akin to a named formula than
a named range. If I refer to Range("x") in code, VBA doesn't know what I'm
talking about.

Regards,

Vasant
 
G

Guest

Tushar - what does the code in the name box actually look like. I can't get
it to work. Just 1 example will do. Thanks
 
V

Vasant Nanavati

Tushar Mehta said:
The easiest way is to let XL do the work. Rather than typing the
range, I used the mouse to select the 2 sheets then the range. XL put
a single quote around the sheet1:sheet2 part.

Hi Tushar:

I think I'm brain-dead this week ... I couldn't get this to work either. If
I select both sheets and then select a range and name it, the name seems to
apply only to the selected range on the active sheet. I tried doing this
with the Name Box as well as with the Define Name dialog.

Regards,

Vasant
 
G

Guest

Actually Tushar I am referring to the code or reference that appears in the
"Define Name" dialogue box under Insert/Name/Define menu
 
T

Tushar Mehta

Similar to Harlan's first post in this discussion:
=Sheet1:Sheet2!$A$1:$D$1

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
T

Tushar Mehta

I invariably forget to use the Name Box since as often as not I'm
creating named formulas.

The way I did this was to get to the Define name dialog box, enter a
name, tab to the 'refers to' field then use the mouse to select sheet1,
SHIFT+sheet2 tab. At this point the 'refers to' field contains
='Sheet1:Sheet2'!

Next, click on A1 and drag-extend the selection to D1. The 'refers
to' field contains ='Sheet1:Sheet2'!$A$1:$D$1 Back in the dialog box,
click OK.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
V

Vasant Nanavati

Hi Tushar:

Interesting ... I had tried to do it using the Ctrl key and it didn't work.
But of course, the Shift key makes more sense for a 3D range, even for 2
sheets.

Regards,

Vasant
 
G

Guest

Tushar - now I have the range names and it works for the sum function but I
do not seem to be able to reference teh range with V/HLOOKUP which is really
why I want the extra spreadhseets in the range (needless to say I have price
tables that don't fit on one sheet). Any thoughts as to how to resolve this.
Thanks David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top