cannot shift nonblank cells

joemeshuggah

Board Regular
Joined
Jul 18, 2008
Messages
161
i have a macro that deletes all rows from row 4 to 65536.

i then paste results from a query in row 4, and then run a macro that loops through each column, adds a column, and adds a ranking formula. sometimes, but not all of the time, i get an error message saying:

Run-time error '1004'

To prevent possible loss of data, Microsoft Excel cannot shift nonblank cells off the worksheet.

Try to locate the last nonblank cell by pressing CTRL+END, and delete or clear all in cells between the last cell and the end of your data. Then select cell A1 and save your workbook to reset the last cell used.

When i hit CTRL+END, I arrive at a cell, but it is blank. If I delete everything, the problem still occurs. Anyway around this?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Are you using insert to add a column?
Maybe you need to delete all unused columns to the right of your data?

What cell is selected when you press F5, Special, LastCell, and click OK?

Maybe there's an object hiding out there you can't see?
Try pressing F5, Special, Objects, and click OK. Press delete key if it doesn't report "No Objects Found".
 
Upvote 0
i checked around on google and there were help files on microsofts web site that indicated you need to delete all blank cells outside of your data range, save, and re-open. when i did this, my macro worked just fine.

any idea on why this is required? it gets very cumbersome to have to do this (it is for a report that is updated daily)
 
Upvote 0
If you do that once, I would think, that should fix it.
Unless your macro is somehow re-populating cells when it runs.
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top