Microsoft KB Archive/165779

= XL97: External Data Range Property Not Saved with Workbook =

Article ID: 165779

Article Last Modified on 11/23/2006

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition

-



This article was previously published under Q165779



SYMPTOMS
In Microsoft Excel 97, the "Overwrite existing cells with new data, clear unused cells" option in the External Data Range Properties dialog box is not retained when you save and close a workbook. Instead, the "Insert entire rows for new data, clear unused cells" option is selected.



CAUSE
This problem occurs in a workbook that already contains external data ranges.



WORKAROUND
Microsoft provides programming examples 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. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

https://partner.microsoft.com/global/30000104

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

To use one or more external data ranges in a workbook and use the "Overwrite existing cells with new data, clear unused cells" option, create and run a Visual Basic for Applications macro to reset the option each time you open the workbook. To do this, follow these steps:  Write down the name of the worksheet that contains the external data range (for example, "Sheet1"). Right-click any cell in the external data range, and click Data Range Properties on the shortcut menu. Write down the name in the Name box (for example, "ExternalData1"). Then, click Cancel. On the Tools menu, point to Macro, and click Visual Basic Editor (or press ALT+F11). In the Project window, double-click ThisWorkbook for the workbook that contains the external data range. In the Code window, click Workbook in the Object list. In the Procedure list, click Open. The "Private Sub Workbook_Open" subroutine appears.  In the subroutine, type the following line of code ActiveSheet.QueryTables("y").RefreshStyle = xlOverwriteCells where "y" is the name of the data range you wrote down in step 2. </li> On the File menu, click "Close and Return to Microsoft Excel."</li></ol>

For each external data range that will use the "Overwrite existing cells with new data, clear unused cells" option, repeat these steps. When you are finished, save the workbook.

When you open the workbook, the data ranges are formatted correctly.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem no longer occurs in Microsoft Excel 2000.

<div class="moreinformation_section">

MORE INFORMATION
In Microsoft Excel 97, you can use the Run Web Query, Run Database Query, and Create New Query commands (on the Get External Data submenu) to retrieve external data. When you retrieve external data and the number of rows in the external data range changes, you can format the external data range in the worksheet in one of three ways. To do this, follow these steps:


 * 1) Right-click any cell in the data range. On the shortcut menu, click Data Range Properties.
 * 2) Under Data Layout, select one of the following three options, depending on how you want Microsoft Excel to behave when data is updated:


 * 1) * Insert cells for new data, delete unused cells
 * 2) * Insert entire rows for new data, clear unused cells
 * 3) * Overwrite existing cells with new data, clear unused cells
 * 4) Click OK.

If you click either of the first two options, the option is saved with the workbook. However, if you click the third option (to overwrite cells), it reverts to the second option (to insert entire rows) when you close the workbook.

Additional query words: XL97

Keywords: kbprb kbweb KB165779

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.