Microsoft KB Archive/166813

= 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