Guest User

Untitled

a guest
Sep 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. function CreateNewProject() {
  2.  
  3. var ThisSheet = SpreadsheetApp.getActive(); //Selects the sheet (should have the macro button)
  4. var LastRow = ThisSheet.getLastRow(); // The last row that has been entered in the spreadsheet
  5. var LastCellString = "A"+LastRow+":A"+LastRow; // The string representing the last cell to position to
  6. var LastCell = ThisSheet.getRange(LastCellString); // The internal variable of the last cell
  7.  
  8. var R = LastCell.getRowIndex(); //set value for insertRowsAfter
  9.  
  10. var LastRowPlusOne = ThisSheet.getLastRow() + 1;
  11. var LastCellStringPlusOne = "A"+LastRowPlusOne+":A"+LastRowPlusOne;
  12. var LastCellPlusOne = ThisSheet.getRange(LastCellStringPlusOne);
  13.  
  14.  
  15. ThisSheet.setActiveRange(LastCell) // Actually perform the repositioning to the last cell
  16. ThisSheet.insertRowsAfter( R, 1 ); //inserts a new row at the bottom of the sheet
  17. ThisSheet.setActiveRange(LastCellPlusOne) //adjusts active cell
  18. ThisSheet.getRange('2:2').copyTo(ThisSheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false); //copy & pastes formulas into the last row
  19.  
  20. ThisSheet.getActiveRange().setValue("MaxValuePlusOne"); //sets value for Column A for the last row -- this needs to be Max +1 of all values in column A
  21.  
  22. };
Add Comment
Please, Sign In to add comment