I'm tearing my hair out here...
I'm trying to copy an array from one sheet in one spreadsheet and then paste it into a different spreadsheet and sheet.
Here is my script so far:
function sortedNewClasses() {
var comesFromSpreadsheet = SpreadsheetApp.getActive();
var fromSheet = comesFromSpreadsheet.getActiveSheet();
var intosheet = masterss.getSheetByName("Copy of MasterMain9th");
var newLinesNeeded = comesFromSpreadsheet.getRange("A1").getValue();
Logger.log(newLinesNeeded);
var arrayOfInfo = fromSheet.getRange(3,1,4,178).getValues();
Logger.log(arrayOfInfo);
var test = intosheet.getRange(3,1,3,4).getValues();
Logger.log(test);
The fromsheet looks like this:
4
2127 Shaw Samantha
2127 Shaw Samantha
2127 Shaw Samantha
2127 Shaw Samantha
My 3 logger.log()s return this:
Logger.log(newLinesNeeded); //returns 0, should be 4
Logger.log(arrayOfInfo); //returns [[#N/A, , , , , , , , , , , Smith, T, 01/17/2023, 05/26/2023, 7799-21, A,B/RP, Advisory, Y, #N/A, , 4, 4, 4, 4, 4,
//should be [[2127, Shaw, Samantha], [2127, Shaw, Samantha], [2127, Shaw, Samantha], [2127, Shaw, Samantha]
This is all truncated examples as the actual sheet has 178 columns and 24 rows.
The 3rd Logger.log returns correct information, but it is accessing the sheet I am sending the information to, not the one it is coming from.
Logger.log(test); //gives me [[2408, Allmon, Aaron, ], [2408, Allmon, Aaron, ], [2408, Allmon, Aaron, ]] which is absolutely correct.
I've tried pointing the getRange().getValues() at different cells but the result is always the same. I tried referencing the sheet I'm pulling info from with openByURL and getSheetByName() but I get the same wrong values regardless.
I've never had a problem like this before. Anyone have an idea of how to fix it? Ironically, a similar script was working just fine in the same Spreadsheet but a different sheet this morning. When I started scripting for the next sheet, it all stopped working, even the original sheet that had been working earlier.