Microsoft KB Archive/119084

= Macro to Delete Link Between List Box and Range of Cells =

Article ID: 119084

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0 Standard Edition
 * Microsoft Excel 5.0 for Macintosh

-



This article was previously published under Q119084



SUMMARY
In Microsoft Excel, when you assign values to the List property of the ListBoxes object, the link for that list box is cleared. If you want to remove the link but leave the values that resulted from the link, you can reassign the List property of the list box to the values from the worksheet, and the values will remain even though the link is broken.

This article contains a sample Microsoft Visual Basic for Applications macro that breaks the link between a list box (or a drop-down list box) on a dialog sheet and a worksheet range but leaves the values from that range in the box.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements.

To Create a Dialog Box With a Linked List Box

 * 1) In a new workbook, create a dialog sheet, and name it Dialog Example.
 * 2) In the dialog sheet, create a list box, and name it ListBox.
 * 3) Select the list box, and on the Format menu, click Object. In the Input Range box, enter the worksheet range that contains the list that you want to appear in the list box.

To Create a Visual Basic Macro to Break the Link but Leave the List
 On the Insert menu, click Macro, and then click Module.  On the module sheet, enter the following macro code: Sub break_link Dialogsheets(1).ListBoxes("ListBox").List = _ Dialogsheets(1).ListBoxes("ListBox").List End sub NOTE: If you are using a drop-down box, substitute the DropDowns object for the ListBoxes object in the code above.  On the Tools menu, click Macro, select the break_link macro, and click Run.

When you select the list box on the dialog sheet and click Object on the Format menu, note that the Input Range box is empty but the list box still contains the values from the worksheet range.

In Microsoft Excel, you can place values in a list box or in a drop-down box by linking the box to a range on a worksheet To do this, select the box, and click Object on the Format menu. Then, enter the desired range in the Input Range box.

Additional query words: 5.00c XL

Keywords: kbcode kbhowto kbprogramming KB119084

-

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

© Microsoft Corporation. All rights reserved.