Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Specifying Location for a Message Box.

Specifying Location for a Message Box

Written by Allen Wyatt (last updated August 28, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


3

Leonard wonders if, when displaying a message box in a macro, there is a way to force the box to appear at a specific location on the screen.

There is no way to do this, as the MsgBox function doesn't include any way to specify a location. Instead, Excel displays the message box centered on the screen. If you need the capability to position the box, then the easiest solution is to rely upon the InputBox function. Unlike MsgBox, InputBox includes option parameters for specifying a location. Here's an example:

sName = InputBox(Prompt:="Enter your name", XPos:=2880, YPos:=1440)

Note that you can specify both an X position and a Y position for the upper-left corner of the box. The values assigned to these parameters are measured from the top-left corner of the screen, and are specified in twips. (There are 1440 twips to an inch.)

An input box does, of course, expect the user to provide input, whereas a message box does not. If you don't want to potentially confuse your users by soliciting input when none is really needed, then you'll need to create a UserForm to simulate a message box.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10030) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Specifying Location for a Message Box.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Using the Copy or Move Text Keys

Most people use the Clipboard to copy and move text in Word. Before the Clipboard, Word used F2 to move text and Shift+F2 ...

Discover More

Default Picture Location

When you insert pictures into a document, the first folder that Word opens up is normally the My Pictures folder. You can ...

Discover More

Rounding in Results

Rounding is a fact of life when it comes to using formulas in a worksheet. Sometimes that rounding can be a bit ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Editing Macros

Even if you do nothing but record macros, sooner or later you will have a need to edit what you record. Here's how to get ...

Discover More

Clean Up Your Macro List

Got a workbook cluttered with all sorts of macros? Delete them and you'll make your workbook easier to manage.

Discover More

Using the Status Bar

When developing a macro, you may want to display on the status bar what the macro is doing. Here's how to use this ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 6 - 0?

2022-04-20 15:02:47

improveyourcoding

thx


2021-09-05 07:24:21

Jim Comin

Regarding location of message boxes, I was trying to figure out how to change the location, when thankfully I checked in with you and found that you can't.

You can, however, drag them around once opened. I had just created one that is right smack in the way of the users work, so I just added a notation in the message box that says, "you can drag it out of the way if it is interfering with your view."


2021-08-28 10:11:25

J. Woolley

My Excel Toolbox includes Sub MsgBoxCustom and Function MsgBox_Custom, which display a standard MsgBox with custom position and/or button labels. The custom position can be absolute screen coordinates or relative to a cell.
My Excel Toolbox also includes Function InputBoxVBA_Custom and Function InputBoxApp_Custom with screen coordinate or cell-relative positioning.
See https://sites.google.com/view/MyExcelToolbox/


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.