ssbot icon indicating copy to clipboard operation
ssbot copied to clipboard

everyRotate() Loses a Value

Open wmodes opened this issue 7 years ago • 2 comments

When an Every tweet goes out, it removes the first tweet at B3 and moves the list up, but does not rotate the first tweet to the bottom.

function everyRotate(){
    var everySheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Every");      
    var lastRow = everySheet.getLastRow();
    var nextLastRow = lastRow + 1;
    
    // copy the value of row 3 to the end of the column
    var nextValues = everySheet.getRange("b3:z3").getValues();
    everySheet.getRange("b"+lastRow+":z"+lastRow).setValues(nextValues);
    everySheet.deleteRow(3);
  
}

Perhaps you meant to do something with nextLastRow?

wmodes avatar May 16 '17 23:05 wmodes

Perhaps this is more like what you intended. This rotates (rather than slowly nukes) the list.

    var everySheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Every");      
    var lastRow = everySheet.getLastRow();
    var nextLastRow = lastRow + 1;
    
    // copy the value of row 3 to the end of the column
    var justTweetedValues = everySheet.getRange("b3:z3").getValues();
    everySheet.getRange("b"+nextLastRow+":z"+nextLastRow).setValues(justTweetedValues);
    // now remove row 3 which will move everything up one
    everySheet.deleteRow(3);
}

wmodes avatar May 16 '17 23:05 wmodes

It appears that the current version works around this by using a next--> pointer that moves instead of actually rotating the values.

antgiant avatar Aug 02 '19 12:08 antgiant