Controlling Appearance of Mouse Pointer Within Macro

Article translations Article translations
Article ID: 130044 - View products that this article applies to.
This article was previously published under Q130044
Expand all | Collapse all

On This Page


In Microsoft Excel 97 and 7.0, you can use the Microsoft Visual Basic for Applications Cursor property to control the appearance of the mouse pointer while a macro is running. In earlier versions of Microsoft Excel, you do not have this ability to change the way the mouse pointer is displayed.


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. In Microsoft Excel version 5.0, the mouse pointer is normally displayed as an hourglass when you run a macro. The exception to this is when you run a macro from a control in a custom dialog box. In this case, the mouse pointer continues to be displayed as an arrow, and does not give you an indication that the macro (event procedure) is running.

In Microsoft Excel versions 7.0 and 97, you can use the Cursor property to display the mouse pointer as an arrow, an hourglass, an I-beam (displayed when editing text), and the default pointer. The following built-in constants correspond to each of the available cursor shapes:
   xlNorthwestArrow    The northwest-arrow pointer
   xlWait              The hourglass pointer
   xlIBeam             The I-beam pointer
   xlNormal            The default pointer
Note that when you type in the constant for the I-beam pointer, the letter that follows the "xl" prefix is an "I" (for I-beam).

Cursor Property Example

Sub ChangePointer()

    ' Display dialog box indicating mouse pointer will change.
    MsgBox "Click OK to display mouse pointer as hourglass."

    ' Display mouse pointer as hourglass.
    Application.Cursor = xlWait

    ' Wait so mouse pointer change will be noticeable.
    Application.Wait Now + TimeValue("0:0:03")
    MsgBox "Click OK to display mouse pointer as arrow."

    ' Display mouse pointer as arrow
    Application.Cursor = xlNorthwestArrow

    ' Wait so mouse pointer change will be noticeable.
    Application.Wait Now + TimeValue("0:0:03")

    MsgBox "Click OK to display mouse pointer as I-beam."

    ' Display mouse pointer as I-beam.
    Application.Cursor = xlIBeam

    ' Wait so mouse pointer change will be noticeable.
    Application.Wait Now + TimeValue("0:0:03")

    MsgBox "Click OK to return mouse pointer to normal."

    ' Return mouse pointer to normal display.
    Application.Cursor = xlNormal

End Sub
Note that because the Cursor property isn't automatically reset when the macro stops running, you should reset the mouse pointer by setting the Cursor property to the xlNormal value before your macro stops.


For more information about the Cursor property in Microsoft Excel 97, from

the Visual Basic Editor, click the Office Assistant, type Cursor, click Search, and then click to view "Cursor Property."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:
176476 OFF: Office Assistant Not Answering Visual Basic Questions


Article ID: 130044 - Last Review: October 11, 2006 - Revision: 2.3
  • Microsoft Excel 97 Standard Edition
  • Microsoft Excel 95 Standard Edition
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from