Microsoft Knowledge Base

XL: Consolidate Method Requires R1C1 Notation

Last reviewed: July 3, 1997
Article ID: Q166813
The information in this article applies to:
  • Microsoft Excel 97 for Windows
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Excel for Windows, versions 5.0, 5.0a, 5.0c
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a
  • Microsoft Excel for the Power Macintosh, versions 5.0, 5.0a

SUMMARY

In the versions of Microsoft Excel listed above, if you are using the Consolidate Method in a Visual Basic for Applications macro and you are referencing a range using A1 notation, the following may occur:

   - The consolidation will not return any values, nor will it return
     an error message.

     -and-

   - The sheet names will be not be referenced in the All References edit
     box in the Consolidate dialog box.

MORE INFORMATION

The Consolidate Method requires that the you reference the range using R1C1 notation.

Microsoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

The following example assumes that the workbooks you want to consolidate are open in Microsoft Excel 97 and that the workbook where you want to perform the consolidation is named "Target.xls" (without quotation marks).

NOTE: The file name "Target.xls" is case sensitive in the macro below. Make sure that the file name you are using matches the file name used in the macro.

   Option Base 1
   Sub test()
   Dim books() As String     'dims the array
   ArrayNum = ArrayNum + 1   'dims the counter
   SheetName = "sheet1!"     'dims the worksheet reference
   Reference = "r1c1:r1c3"   'dims the reference to $A$1:$C$1

   For Each w In Workbooks
   'The following line tests to see if the active workbook is
   'the consolidation target workbook named "Target.xls"
        If w.Name <> "Target.xls" Then
           ReDim Preserve books(ArrayNum)
           books(ArrayNum) = "[" & w.Name & "]" & SheetName & Reference
           ArrayNum = ArrayNum + 1
        End If
   Next
   Workbooks("Target.xls").Activate
   Sheets("sheet1").Select
   Range("a1").Select
   Selection.Consolidate sources:=books, Function:=xlSum, TopRow:=False,
LeftColumn:=False, CreateLinks:=False
   End Sub

REFERENCES

For more information about the Consolidate Method, click the Office Assistant in Microsoft Visual Basic Help, type the following text

   Consolidate

and then click the the "Consolidate Method" topic.


Keywords : kbhowto kbprg
Version : 5.00 5.0a | 5.00 5.0a 5.0c 7.00
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 3, 1997
©1997 Microsoft Corporation. All rights reserved. Legal Notices.