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.
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:
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.
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!
When processing workbook information in a macro, you may need to step through each worksheet to make some sort of ...
Discover MoreExcel allows you to "freeze" rows in your worksheet. What if you want the rows that are frozen to change as you scroll ...
Discover MoreEver want to use the name of a worksheet tab within a cell? Here's how you can access that information using the CELL ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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 )
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments