First question in here, I've been getting info from here by searching posts for weeks but I'm a bit stuck right now. I'm trying to set up sending data and time stamps from several Google Spreadsheets set up as input forms for individual people, and to set each of those to send data with a script to a collating spreadsheet that will append any fresh data into columns specific for those people. Thus, I need to get either the last row of data of the specific column +1, or the first empty cell of said column.
I could do it with A1 notation calls for range, but then I would have to set each input spreadsheet up with the correct column and reordering columns would mess it up. I'm trying to call specific columns by a name string or named range (e.g., column with header of "John Doe" or named range "John_Doe") so I can then put that same name in as a variable once (e.g. name = John_Doe for rest of function) and not have to worry about messing up column number typos. My comments have some alternatives I've been trying too.
As a bonus, I'm trying to offset a time stamp for each submission one column right of the first cell with data put in it, but I think that will be easier to figure out if I can correctly call the starting empty cell of a specific column by the method above.
//Use the same name for this variable as the protected range name for that person. E.g., John_Doe
//****GLOBALS****
//var name = "John_Doe"
function SendDataAndTimestamp() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var sourceRange = ss.getRange('C6:C401'); //assign the range you want to copy
var data = sourceRange.getValues();
var tss = SpreadsheetApp.openById('1d0C5AfqHvaCdVA6hHZRO5pcp8xm_wJkQXN0XhHiJy60'); //replace with destination ID
var ts = tss.getSheetByName('All Tallies'); //replace with destination Sheet tab name, will probably be the same on the actual version
//Debugger didn't like me using var tr = ts.getRangeByName, not sure why
var tr = tss.getRangeByName("John_Doe");
//Time stamp info. Will need to update getRange to same specific column as the data, and to use offset from that instead of direct column number.
var date = new Date();
//tr.getRange(tr.getLastRow()+1, +1).setValue(date).setNumberFormat("MM/dd/yyyy HH:mm:ss");
trLR = tr.getRange(tr.getLastRow+1, tr.getLastColumn, 396);
trLR.setValues(data);
//tr.getRange(tr.getLastRow()+1, tr, 396).setValues(data);
/*Need to add variables for finding a specific column by name
Need to adjust getLastRow to that specific column
Need to offset date and time stamp one right of (getLastRow+1 specific column)
In the data, may want to check it and give prompt to user if any incorrect (not a number between 1000 and 9999)
*/
}