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

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
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,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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