Copy and paste lines

All2Cheesy

Board Regular
Joined
Mar 4, 2015
Messages
127
Hi all,

I've written a macro which copies a line, and pastes it down X amount of times (determined by a number in another field) However, when I run this macro, some of the formulas affected remove 'X' from the numbers in the formula.

e.g. assuming X is 50
if('A652'=1,"Y","N") will become if('A602'=1,"Y","N") in the formula.
Please note, the macro still works, as it will copy the formula down to the correct amount of lines, I am simply looking to have it do this without subtracting numbers from my formula.

Code:
Range("A652:AB652").Copy
Range("A652:AB652").Resize(Range("T2").Value).Insert Shift:=xlDown

Assistance would be greatly appreciated.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Edit:

I've pinpointed the piece of code which is altering the numbers in my formulas.

Code:
'Add Lines
    Application.Calculation = Manual
    Range("A652:AB652").Copy
    Range("A653:AB653").Resize(Range("T2").Value).Insert Shift:=xlDown
'Clear Lines
    Range("A653:B1000").Select
    Selection.ClearContents
    Application.Calculation = xlAutomatic
    
    ThisWorkbook.Sheets("Summary (Parcel)").Activate
    ActiveSheet.Unprotect password:=password
'Add Lines
    Application.Calculation = Manual
    Range("A652:AB652").Copy
[COLOR="#FF0000"]    Range("A653:AB653").Resize(Range("T2").Value).Insert Shift:=xlDown[/COLOR]
'Clear Lines
    Range("A653:B1000").Select
    Selection.ClearContents
    Application.Calculation = xlAutomatic

The bizarre thing is, there's only one column where the formula is changing incorrectly. This is column M, in the summary(bulk) sheet, even though the point in which the code changes is not when the macro is referencing this page.
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,665
Members
449,462
Latest member
Chislobog

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