PDA

View Full Version : Excel guru please: Error cannot shift nonblank cells



WhiteD3
19th May 2010, 12:25 PM
I have a multi-tab 2007 workbook where the user can, via a button and VBA code, add and delete columns in one tab, at which time the matching column(s) in another tab are added or deleted.

If I delete a column, then immediately add a column, Excel gives me a runtime error 1004 "cannot shift non blank cells off the worksheet".

If I just add columns there's no error.

If I add then save, close, re-open, then delete, there's no error.

Following the code execution, the error occurs when the code adds the column to the second tab. Looking at the column formatting on the RHS of the sheet, some formating (borders) appear in some cells in the far RH column each time I delete a column.

I have checked the code and at no time reference this end column.

Makes no sense to me at all. Any ideas please?

Dorko
19th May 2010, 03:41 PM
Whats the code?

Dorko

WhiteD3
19th May 2010, 04:53 PM
Whats the code?

Dorko

Dorko, PM me your email address and I'll send you the file if you like. Tried to PM you but you're blocking PMs.

Dorko
19th May 2010, 04:55 PM
Sent

Dorko

WhiteD3
22nd May 2010, 09:12 AM
Dorko,

In the end I had to add some code as discussed to clear the formating in that last column. All works well now although the anal retentive in me hates having to do work arounds.

Thanks for your time and help.:D

Dorko
22nd May 2010, 08:04 PM
You have to love the work arounds.... i spend hours on some things, just trying to seek a better solution. Painful!

Dorko :D