Sebastian Schulz
Sebastian Schulz

Reputation: 1

Copy & Paste Script

This is my current script which works wonderfully. The range B5:J100 is currently being copied and pasted to the correct position in the sheet. However, the clearContent area must only start from B7:J100. How can I put that in the script?

Update: Can you show me where i have to write this new section? I am complete new to scripts and dont know how to do this.

 function copyPaste() {
   var ss=SpreadsheetApp.getActive();
   var srcsh=ss.getSheetByName('Yard');
   var dessh=ss.getSheetByName('History Yard');
   var srcrg=srcsh.getRange('B5:J100');
   var data=srcrg.getValues();
   var desrg=dessh.getRange(dessh.getLastRow() + 1,1,96,9);
   desrg.setValues(data);
  
srcrg.clearContent()
   }

Upvotes: 0

Views: 679

Answers (1)

Benibis
Benibis

Reputation: 36

The very easy (and static) way would be to apply clearContent() on sercsh.getRange('B7:J100') instead of srcrg.

If you want that to be (somewhat) dynamic, you could also use Offset on your srcrg variable (offset 2 rows, number of rows decreased with 2).

Upvotes: 1

Related Questions