Problems deleting columns

  • Thread starter Thread starter David
  • Start date Start date
D

David

I am trying to add some columns with the following code:

For i = start To finish
Columns("G:G").Select
Selection.Insert Shift:=xlToRight
Next i

The problem I am having is that I often get the message:

"Run-time error '1004':
To prevent possible loss of data, Microsoftw Excel cannot shift
onblank cell off the worksheet. ...."

I have reset my last cell and saved, but the error returns. Any ideas?

David
 
David

You have data in the last column of your worksheet(IV) and are trying to
insert a column which would shift that data off the sheet and Excel does not
like it.

Clear the data from column IV and your macro will work but bear in mind evey
time you insert a column data is shifted right and the problem will return.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top