ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Problem inserting rows (and cutting) (https://www.excelbanter.com/excel-discussion-misc-queries/252791-problem-inserting-rows-cutting.html)

jodleren

Problem inserting rows (and cutting)
 
Hello

I got a macro to fix, which has worked.

The original code was:

Columns("M:M").Select
Selection.Cut
Range("L1").Select ' was L1
Selection.Insert Shift:=xlToRight

I tried this also:
Range("L1").Select
DoEvents
Range("L1").Insert

and both gives the error:

Runtime error 1004
Insert method of Range class failed.

What can cause this?

WBR
Sonnich

jodleren

Problem inserting rows (and cutting)
 
On Jan 8, 7:22*pm, jodleren wrote:
Hello

I got a macro to fix, which has worked.

The original code was:

* * Columns("M:M").Select
* * Selection.Cut
* * Range("L1").Select ' was L1
* * Selection.Insert Shift:=xlToRight

I tried this also:
* * Range("L1").Select
* * DoEvents
* * Range("L1").Insert

and both gives the error:

Runtime error 1004
Insert method of Range class failed.

What can cause this?

WBR
Sonnich


Adding this does not help

For aa = 1 To ActiveWorkbook.Worksheets.Count
ActiveWorkbook.Worksheets(aa).Unprotect
Next


jodleren

Problem inserting rows (and cutting)
 
On Jan 8, 7:33*pm, jodleren wrote:
On Jan 8, 7:22*pm, jodleren wrote:



Hello


I got a macro to fix, which has worked.


The original code was:


* * Columns("M:M").Select
* * Selection.Cut
* * Range("L1").Select ' was L1
* * Selection.Insert Shift:=xlToRight


I tried this also:
* * Range("L1").Select
* * DoEvents
* * Range("L1").Insert


and both gives the error:


Runtime error 1004
Insert method of Range class failed.


What can cause this?


WBR
Sonnich


Adding this does not help

* * For aa = 1 To ActiveWorkbook.Worksheets.Count
* * * ActiveWorkbook.Worksheets(aa).Unprotect
* * Next


I made this up:

Range("L1").Select
Columns("L:L").Insert
Columns("N:N").Select
Selection.Cut
ActiveSheet.Paste Destination:=ActiveSheet.Range("L:L")

This works.

Any better ideas?

Sonnich


All times are GMT +1. The time now is 06:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com