Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. 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: Shifting Objects Off a Sheet.

Shifting Objects Off a Sheet

Written by Allen Wyatt (last updated June 30, 2023)
This tip applies to Excel 2007 and 2010


11

Mudit ran into problems when trying to delete rows and columns in a worksheet. He sometimes gets the message "Cannot shift object off this sheet." Other people report getting the message when they try to insert rows or column.

What is happening is that an object—such as a graph, drawing object, text box, picture, or even comment—cannot be correctly handled by Excel after the deletion or insertion. If the error occurs when inserting rows or columns, it means that the insertion would push the object beyond the right or bottom boundaries of the worksheet. The solution, of course, is to check whatever is at the right or bottom of the worksheet and make changes to those objects (move or delete them) as necessary.

If the error occurs while deleting rows or columns, it is normally because there are objects attached to cells within those rows or columns, and deleting the rows or columns would leave the objects "orphaned" in some way. For instance, let's say you are deleting column D, and there is an object associated with cell D4. The object doesn't need to be situated over column D; it could be several columns away, but still belong to cell D4. If you delete column D, then the object no longer has an anchor point. Excel's solution? Don't let column D be deleted until you do something with the object that would be orphaned by the edit.

The problem can also occur if the objects in a worksheet are formatted so that they cannot be moved or sized automatically by Excel, and then you try to delete columns or rows associated with the objects. In this case, you may want to try changing the formatting of the objects in the worksheet. If you have a lot of such objects in the worksheet, the following macro can be helpful in making the change:

Sub ResetShapes()
    Dim s As Shape
    On Error Resume Next
    For Each s In ActiveSheet.Shapes
        s.Placement = xlMoveAndSize
    Next
End Sub

Microsoft provides a Knowledge Base article that can be helpful with this problem. The article specifically addresses the issue of hiding rows and columns, but the solutions work when you are trying to delete them, as well. You can check it out at this page:

http://support.microsoft.com/kb/211769

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 (809) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: Shifting Objects Off a Sheet.

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

Ignoring Punctuation in Names

If you have a word that includes punctuation as part of the word itself, then you may be frustrated by how Word treats ...

Discover More

Sorting by Highlighting

The sorting capabilities of Word are quite handy and easy to use. What if you want to sort by something Word doesn't sort ...

Discover More

Converting Dates to Text

Need to use a date as part of a larger string of text? Here are some handy ways to go about the process.

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Creating Worksheets from a List of Names

Need to create a large number of worksheets using specific names? If so, you'll love the ideas presented in this tip.

Discover More

Creating a Copy without Formulas

Excel makes copying worksheets (duplicating them) rather easy. However, you may want a worksheet copy that differs from ...

Discover More

Specifying the Number of Worksheets in a New Workbook

By default, a new Excel workbook contains three blank worksheets. You can (and should) configure Excel to whatever number ...

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 two more than 7?

2019-05-16 11:14:24

MVRDA

I could not delete comments on the sheet, and after I ran the macro it worked again!


2018-01-19 06:20:13

Mich

On my side, got this when refreshing pivot table. Was due to an inserted comment. Solved as soon deleted/removed.


2017-04-07 08:04:33

RKeev

Happens to me due to Comments.
I use this to ensure comments are placed correctly:

Sub MoveComments()
Dim cmt As Comment
For Each cmt In ActiveSheet.Comments
With cmt
.Shape.Top = .Parent.Top
.Shape.Left = .Parent.Offset(0, 1).Left
End With
Next
End Sub


2016-07-18 12:35:13

Joshua

Found so many other sites that offered the same useless solution.

This post was great, and it worked!

Wish I saw this one first.


2016-07-03 18:37:05

Robert Armstrong

All the other posts I found on the internet we totally useless, but this worked straight off, so thank you very much for this.


2015-06-09 20:49:25

Lauren Raymundo

I had the same problem and NOTHING helped me. I could type or copy/paste into the blank columns on the right of my spreadsheet, but could not insert a column. I removed the data filtering and VOILA, it worked.


2015-02-11 08:57:35

ruban

It is not working in my sheet, Please guide me.


2014-09-19 11:42:20

Jan

I'm using 2010 version and I just started getting this when trying to insert row. My spreadsheet has 808 lines of data. I cannot insert even 1 line - HELP!!


2014-07-15 11:21:19

dbjbdbj

COMMENTS
I had the same problem trying to delete all rows below the useful data. Turns out that the COMMENTS I had on some cells in the top row had somehow been made VERY TALL. In fact, when I would enter "Edit Comment" and check the "Format Comment" window, I found that the "Height" was BLANK. When I made the comments short enough such that they fit within the useful data (and not overlap into the rows I was trying to delete), the ERROR STOPPED!


2013-10-08 06:36:09

Youssef Amarir

Hello,

I'm really grateful for this useful tip. It worked immediately!

Youssef


2013-01-16 13:43:35

gerdami

That's amazing. I got this error message today...

However, I won't use .xlMoveAndSize because I hate this resizing feature. I will simply use .xlMove (Move but don't size with cells )


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.