Microsoft Knowledge Base

XL: Linked List Box Returns Incorrect Index Value

Last reviewed: September 13, 1996
Article ID: Q115401
The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a

SYMPTOMS

In the versions of Microsoft Excel listed above, when you use the Microsoft Excel 4.0 macro language to create a custom dialog box, the following two types of dialog box controls will return incorrect index values:

  • A linked list box (dialog box item 16), if the same text string is in the list more than once.

    -or-

  • A drop-down combination edit/list box (dialog box item 22)

WORKAROUND

To work around this problem, change the linked list box item number (cell B4 below) from 16 to 15 (that is, change it to a standard list box). If you are using a drop-down combination edit/list box, change the item number 22 to a 21 (to a standard drop-down list box).

MORE INFORMATION

Steps to Reproduce Behavior

  1. From the Insert menu, choose Macro, and then choose MS Excel 4.0 Macro.

  2. In the macro sheet, type the following macro:

          A1: =DIALOG.BOX(B2:H6)
          A2: =RETURN()
    

  3. In the range B2:G6 of the macro sheet, type the following dialog box information:

          B2:     C2:      D2:      E2: 360  F2: 312   G2: Select Employee
          B3: 6   C3: 7    D3: 11   E3: 171  F3:       G3:
          B4: 16  C4: 7    D4: 43   E4: 171  F4: 224   G4: R10C7:R18C7
          B5: 1   C5: 105  D5: 277  E5: 64   F5:       G5: OK
          B6: 2   C6: 187  D6: 277  E6: 64   G5:       G6: Cancel
    
    

  4. In the range G10:G18, type the list for the list box:

          G10: Sue Brown
          G11: Dave Jones
          G12: John Smith
          G13: Sue Brown
          G14: Al Davis
          G15: Steve Hall
          G16: Terry Carter
          G17: Sue Brown
          G18: Nancy Blum
    

  5. Select cell A1.

  6. From the Tools menu, choose Macro, and choose Run.

  7. Choose the first "Sue Brown" in the list, and choose OK.

The index number returned to H4 is 8 instead of 1.

NOTE: In Microsoft Excel 4.0, you receive the correct result of 1.


KBCategory: kbusage
KBSubcategory:

Additional reference words: 5.00 7.00



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: September 13, 1996
©1997 Microsoft Corporation. All rights reserved. Legal Notices.