Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited tags
Link
clarified my intentions and corrected grammar
Source Link

I have a Google Sheets that is updated daily with new inventory data. Currently I have to insert a column, copy and paste the data from A15-50 into C15-50.

Is there any way to insert a column where column C is (shifting data to the right), copy A15-A50 to C15-50 so that yesterday's data goes into a different column (C), and (A) gets cleared out so new data can be input for the day?

Currently I have to have all data cleared from column C or it will paste the data after any data in the column. ie: C15-50 is clear, but C51 has data so the data posts in C52. I am currently copying one cell at a time using:

function copypasta() {
var sourceSheet = "Sheet1";
var sourceCell = "B15";
var destinationSheet = "Sheet1";
var destinationCell = "C15"; 
var ss = SpreadsheetApp.getActive();
var sourceValue = ss.getSheetByName(sourceSheet).getRange(sourceCell).getValue();
var destSheet = ss.getSheetByName(destinationSheet); 

var destRange = destSheet.getRange(destinationCell); 

var destRow = destRange.getRow(); 

var destCol = destRange.getColumn(); 

var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();
 
 for (var i=destValues.length-1;i>=0;--i) {    if (destValues[i]) break;   }
 if (destValues[i]!="") i=i+1;   destSheet.getRange(destRow+i,destCol).setValue(sourceValue);
    }

then:

 function clearOrder() {
  SpreadsheetApp.getActiveSheet().getRange('C18''C15').setValue('');
}

Could I change

var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();

the script to overwrite the data that is in C15column C? Is there any way to work on the whole range (C15-50) as opposed to doing it one cell at a time?

I have a little scripting experience but I would consider myself an amateur.

I have a Google Sheets that is updated daily with new inventory data. Currently I have to insert a column, copy and paste the data from A15-50 into C15-50.

Is there any way to insert a column where column C is (shifting data to the right), copy A15-A50 to C15-50 so that yesterday's data goes into a different column (C), and (A) gets cleared out so new data can be input for the day?

Currently I have to have all data cleared from column C or it will paste the data after any data in the column. ie: C15-50 is clear, but C51 has data so the data posts in C52. I am currently using:

function copypasta() {
var sourceSheet = "Sheet1";
var sourceCell = "B15";
var destinationSheet = "Sheet1";
var destinationCell = "C15"; 
var ss = SpreadsheetApp.getActive();
var sourceValue = ss.getSheetByName(sourceSheet).getRange(sourceCell).getValue();
var destSheet = ss.getSheetByName(destinationSheet);
var destRange = destSheet.getRange(destinationCell);
var destRow = destRange.getRow();
var destCol = destRange.getColumn();
var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();
 for (var i=destValues.length-1;i>=0;--i) {    if (destValues[i]) break;   }
 if (destValues[i]!="") i=i+1;   destSheet.getRange(destRow+i,destCol).setValue(sourceValue);
 }

then:

 function clearOrder() {
  SpreadsheetApp.getActiveSheet().getRange('C18').setValue('');
}

Could I change

var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();

to overwrite the data that is in C15-50?

I have a little scripting experience but I would consider myself an amateur.

I have a Google Sheets that is updated daily with new inventory data. Currently I have to insert a column, copy and paste the data from A15-50 into C15-50.

Is there any way to insert a column where column C is (shifting data to the right), copy A15-A50 to C15-50 so that yesterday's data goes into a different column (C), and (A) gets cleared out so new data can be input for the day?

Currently I have to have all data cleared from column C or it will paste the data after any data in the column. ie: C15-50 is clear, but C51 has data so the data posts in C52. I am currently copying one cell at a time using:

function copypasta() {
var sourceSheet = "Sheet1";
var sourceCell = "B15";
var destinationSheet = "Sheet1";
var destinationCell = "C15"; 
var ss = SpreadsheetApp.getActive();
var sourceValue = ss.getSheetByName(sourceSheet).getRange(sourceCell).getValue();
var destSheet = ss.getSheetByName(destinationSheet); 

var destRange = destSheet.getRange(destinationCell); 

var destRow = destRange.getRow(); 

var destCol = destRange.getColumn(); 

var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();
 
 for (var i=destValues.length-1;i>=0;--i) {    if (destValues[i]) break;   }
 if (destValues[i]!="") i=i+1;   destSheet.getRange(destRow+i,destCol).setValue(sourceValue);   }

then:

 function clearOrder() {
  SpreadsheetApp.getActiveSheet().getRange('C15').setValue('');
}

Could I change the script to overwrite the data that is in column C? Is there any way to work on the whole range (C15-50) as opposed to doing it one cell at a time?

I have a little scripting experience but I would consider myself an amateur.

deleted 20 characters in body; edited title
Source Link
pnuts
  • 17.8k
  • 5
  • 54
  • 103

Google sheets script, copy Copy one range to another column, then clear the original range

I have a google sheetGoogle Sheets that is updated daily with new inventory data. currently Currently I have to insert a column, copy and paste the data from A15-50 into C15-50.

isIs there any way to insert a column where column C is (shifting data to the right) copy, copy A15-A50 to C15-50 so that yesterdaysyesterday's data goes into a different column (C), and (A) gets cleared out so new data can be input for the day.?

Currently I have to have all data cleared from column C or it will paste the data after any data in the column.

  ie: c15C15-50 is clear, but c51C51 has data so the data posts in c52

C52. I am currently using:

function copypasta() { var sourceSheet = "Sheet1";

var sourceCell = "B15";

var destinationSheet = "Sheet1";

var destinationCell = "C15";

var ss = SpreadsheetApp.getActive();

var sourceValue = ss.getSheetByName(sourceSheet).getRange(sourceCell).getValue();

var destSheet = ss.getSheetByName(destinationSheet);

var destRange = destSheet.getRange(destinationCell);

var destRow = destRange.getRow();

var destCol = destRange.getColumn();

var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();

for (var i=destValues.length-1;i>=0;--i) { if (destValues[i]) break; } if (destValues[i]!="") i=i+1; destSheet.getRange(destRow+i,destCol).setValue(sourceValue);
}

function copypasta() {
var sourceSheet = "Sheet1";
var sourceCell = "B15";
var destinationSheet = "Sheet1";
var destinationCell = "C15"; 
var ss = SpreadsheetApp.getActive();
var sourceValue = ss.getSheetByName(sourceSheet).getRange(sourceCell).getValue();
var destSheet = ss.getSheetByName(destinationSheet);
var destRange = destSheet.getRange(destinationCell);
var destRow = destRange.getRow();
var destCol = destRange.getColumn();
var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();
 for (var i=destValues.length-1;i>=0;--i) {    if (destValues[i]) break;   }
 if (destValues[i]!="") i=i+1;   destSheet.getRange(destRow+i,destCol).setValue(sourceValue);
}

Thenthen:

function clearOrder() { SpreadsheetApp.getActiveSheet().getRange('C18').setValue(''); }

 function clearOrder() {
  SpreadsheetApp.getActiveSheet().getRange('C18').setValue('');
}

var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();

var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();

I have a little scripting experience but I would consider myself an amateur, Thank you for your time and patience.

Google sheets script, copy one range to another column, then clear the original range

I have a google sheet that is updated daily with new inventory data. currently I have to insert a column, copy and paste the data from A15-50 into C15-50

is there any way to insert a column where column C is (shifting data to the right) copy A15-A50 to C15-50 so that yesterdays data goes into a different column (C), and (A) gets cleared out so new data can be input for the day.

Currently I have to have all data cleared from column C or it will paste the data after any data in the column.

  ie: c15-50 is clear, but c51 has data so the data posts in c52

I am currently using:

function copypasta() { var sourceSheet = "Sheet1";

var sourceCell = "B15";

var destinationSheet = "Sheet1";

var destinationCell = "C15";

var ss = SpreadsheetApp.getActive();

var sourceValue = ss.getSheetByName(sourceSheet).getRange(sourceCell).getValue();

var destSheet = ss.getSheetByName(destinationSheet);

var destRange = destSheet.getRange(destinationCell);

var destRow = destRange.getRow();

var destCol = destRange.getColumn();

var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();

for (var i=destValues.length-1;i>=0;--i) { if (destValues[i]) break; } if (destValues[i]!="") i=i+1; destSheet.getRange(destRow+i,destCol).setValue(sourceValue);
}

Then

function clearOrder() { SpreadsheetApp.getActiveSheet().getRange('C18').setValue(''); }

var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();

I have a little scripting experience but I would consider myself an amateur, Thank you for your time and patience.

Copy one range to another column, then clear the original range

I have a Google Sheets that is updated daily with new inventory data. Currently I have to insert a column, copy and paste the data from A15-50 into C15-50.

Is there any way to insert a column where column C is (shifting data to the right), copy A15-A50 to C15-50 so that yesterday's data goes into a different column (C), and (A) gets cleared out so new data can be input for the day?

Currently I have to have all data cleared from column C or it will paste the data after any data in the column. ie: C15-50 is clear, but C51 has data so the data posts in C52. I am currently using:

function copypasta() {
var sourceSheet = "Sheet1";
var sourceCell = "B15";
var destinationSheet = "Sheet1";
var destinationCell = "C15"; 
var ss = SpreadsheetApp.getActive();
var sourceValue = ss.getSheetByName(sourceSheet).getRange(sourceCell).getValue();
var destSheet = ss.getSheetByName(destinationSheet);
var destRange = destSheet.getRange(destinationCell);
var destRow = destRange.getRow();
var destCol = destRange.getColumn();
var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();
 for (var i=destValues.length-1;i>=0;--i) {    if (destValues[i]) break;   }
 if (destValues[i]!="") i=i+1;   destSheet.getRange(destRow+i,destCol).setValue(sourceValue);
}

then:

 function clearOrder() {
  SpreadsheetApp.getActiveSheet().getRange('C18').setValue('');
}
var destValues = destSheet.getRange(destRow,destCol,Math.max(1,destSheet.getLastRow()-destRow+1)).getValues();

I have a little scripting experience but I would consider myself an amateur.

Source Link
Loading