XL5 Err Msg: "Not Enough Memory" With Indirect Defined NamesID: Q109209
|
In Microsoft Excel version 5.0, defined names are normally limited to 20 levels of indirection. If you use a defined name that exceeds this limit, you will receive the "Not enough memory" error message.
A level of indirection in defined names is created when one name refers
to another name or to a cell reference.
If you have the following names defined in a workbook (Book1)
Name Refers to Level of indirection
--------------------------------------------
Test1 =Sheet1!$A$1 1
Test2 =Book1!Test1 2
Test3 =Book1!Test2 3
Test4 =Book1!Test3 4
Test5 =Book1!Test4 5
Test6 =Book1!Test5 6
Test7 =Book1!Test6 7
Test8 =Book1!Test7 8
Test9 =Book1!Test8 9
Test10 =Book1!Test9 10
Test11 =Book1!Test10 11
Test12 =Book1!Test11 12
Test13 =Book1!Test12 13
Test14 =Book1!Test13 14
Test15 =Book1!Test14 15
Test16 =Book1!Test15 16
Test17 =Book1!Test16 17
Test18 =Book1!Test17 18
Test19 =Book1!Test18 19
Test20 =Book1!Test19 20 (the limit)
Test21 =Book1!Test20 21
where each line represents one level of indirection, and if you attempt to
use a name that exceeds the 20th level of indirection, you will
receive the "Not enough memory" error message.
'----------------------------------------------------------------------<BR/>
Option Explicit
Sub CreateNames()
'Dimension some variables.
Dim X As Integer
'Create the name "Test1", which refers to Sheet1!$A$1.
ActiveWorkbook.Names.Add Name:="Test1", RefersTo:="=Sheet1!$A$1"
'Iterate through the loop 20 times, creating the names "Test2"
'through "Test21".
For X = 2 To 21
'Create the name "Test(X)", which refers to the name "Test(X-1)".
'For example, Test2 refers to Test1, Test3 refers to Test2, etc.
'IMPORTANT: These two lines should be entered as one line.
ActiveWorkbook.Names.Add Name:="Test" & X, _
RefersTo:="=Book1!Test" & X - 1
Next 'loop until all done
End Sub
'----------------------------------------------------------------------
Additional query words: 5.00
Keywords :
Version : 5.00
Platform : WINDOWS
Issue type :
Last Reviewed: August 3, 1999