Excel: Keyboard Shortcut Key Does Not Appear Correctly

Last reviewed: July 16, 1997
Article ID: Q89183

The information in this article applies to:
  • Microsoft Excel for Windows, versions 3.0, 4.0
  • Microsoft Excel for the Macintosh, versions 3.0, 4.0

SUMMARY

In a Microsoft Excel custom dialog box, a single text item (number 5) can have multiple lines if an appropriate width and height is specified for the item. However, in Microsoft Excel for Windows, using an ampersand (&) to assign a keyboard shortcut for selecting the associated edit box or list box will result in an underscore being added not only to the first line, but to each subsequent line in the text string. The underscore in the subsequent lines appears in the same position as the underscore in the first line. Only the letter underlined in the first line will activate the associated edit box or list box.

In Microsoft Excel for the Macintosh, if a width and height is specified for the text item, the underscore will not appear in either a single line or multiple line text item when the dialog box is displayed.

MORE INFORMATION

Using an ampersand to designate a keyboard shortcut will only work correctly with single line text items. If you have multiple lines and wish to use a keyboard shortcut, use a separate text item for each line.

Example

  1. Enter the following into a macro sheet:

    B1:    C1:      D1:     E1: 320   F1: 144  G1:             H1:
    B2: 1  C2: 201  D2:  6  E2:  88   F2:      G2: OK          H2:
    B3: 2  C3: 200  D3: 34  E3:  88   F3:      G3: Cancel      H3:
    B4: 5  C4:  18  D4:  6  E4: 140   F4:  80  G4: E&nter your
                                                   name, rank
                                                   and serial
                                                   number (on one
                                                   line)
    B5: 6  C5:  18  D5: 68  E5: 160   F5:      G5:             H5:
    
    

  2. To display the custom dialog box, create the following macro:

A1: =DIALOG.BOX(B1:H5) A2: =RETURN()

  1. Select cell A1. Choose Run from the Macro menu and then choose the OK button.

The text item in the following dialog box definition table will result in three lines of text. In Microsoft Excel for Windows, the second letter of each line will be underlined; however, only the "n" in the first line will activate the edit box. In Excel for the Macintosh, no underscores will appear.

Breaking the multiple line text item into 3 single line text items as in the following definition table will allow the underline to appear normally.

B1:     C1:      D1:      E1: 320  F1: 14  G1:               H1:
B2: 1   C2: 201  D2:      E2:  88  F2:     G2: OK            H2:
B3: 2   C3: 200  D3: 34   E3:  88  F3:     G3: Cancel        H3:
B4: 5   C4:  18  D4:  6   E4:      F4:     G4: E&nter your name,
B5: 5   C5:  18  D5: 20   E5:      F5:     G5: rank and serial
B6: 5   C6:  18  D6: 34   E6:      F6:     G6: number
B7: 6   C7:  18  D7: 68   E7: 160  F7:     G7:               H7:

REFERENCES

"Microsoft Excel User's Guide 2," version 4.0, pages 263-280


Additional query words: 3.0 3.00 4.0 4.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: July 16, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.