title: Google Spreadheet Script to save and load data to another sheet
body: <p>First of all, thank you to the community for helping each other out!</p>
  
  <p>I'm a teacher and i'm building a spreadsheet to use for grading students. More specifically, my spreadsheet has a couple of sheets: Input, Variables, Data (and for now 'Test') that contain the following:  </p>
  
  <p><strong>Input</strong></p>
  
  <ul>
  <li>Name selection (pulldownmenu using names list on Data-sheet) (cell B3)</li>
  <li>List of criteria with corresponding list of pulldown menu's that are set to
  yes/no (or other options, based on lists in Variables-sheet) (column D)</li>
  <li>Calculation of grades</li>
  </ul>
  
  <p><strong>Variables</strong>  </p>
  
  <ul>
  <li>A couple of lists such as Yes/No, or Good/Average/Bad, etc for use in
  pulldownmenu's on the Input-sheet</li>
  </ul>
  
  <p><strong>Data</strong>  </p>
  
  <ul>
  <li>A list of student names, for use in the pulldown menu for name
  selection on the Input-sheet</li>
  </ul>
  
  <p><strong>Test</strong></p>
  
  <ul>
  <li>This sheet is used for testing my scripts</li>
  </ul>
  
  <p><strong>Grades</strong></p>
  
  <ul>
  <li>This sheet is used for collecting student grades</li>
  </ul>
  
  <p>To fully understand what I'm talking about, please take a look at the sheet in question here: <a href="https://docs.google.com/spreadsheets/d/1IHdlEhjBLBEyqopbicthQLdaGxtH3_1gt1sNOvRlwgo/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1IHdlEhjBLBEyqopbicthQLdaGxtH3_1gt1sNOvRlwgo/edit?usp=sharing</a></p>
  
  <p>Now, the functionality (workflow) I'm looking for is the following:  </p>
  
  <ol>
  <li>On the Input sheet: I choose a student's name from the list, fill out his results (this sheet will calculate the grade) and click a save button. This will copy the results-column to the Test-sheet, where it will be pasted as a row behind the corresponding name.<br>
  <strong>So far so good</strong> (I've managed to get this to work.)  </li>
  <li>At the same time the grades will have to be copied to the Grades-sheet. This is where it gets a bit confusing to me, for i need to have some way of selecting the grades from the Input-sheet. I was thinking i could select values based on cell backgroundcolor or FontSize or something similar, but i can't get it to work.</li>
  <li>When the grades are saved in the Grades-sheet i will be able to use
  them in other sheets for the purpose of reviewing and comparing.
  When a students results have been entered and saved, i also need the
  option to load the data from the Test-sheet back into the Input
  sheet. So basically, this does the Save operation the other way
  around; it finds the correct data by comparing the selected name on
  the Input-sheet with the list of names on the Test-sheet and then
  copies the corresponding results row and pastes it as a column into
  the Input-sheet.</li>
  </ol>
  
  <p>The code i have been using so far:</p>
  
  <pre><code>function Save() {
    var sourceSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Input');
    var targetSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('test');
  
    var studentName = sourceSheet.getRange('B3').getValue(); //returns the name of the current student
    var studentResult = sourceSheet.getRange(5,4,sourceSheet.getLastRow()).getValues(); //returns the results of the current student
  
    var columnValues = targetSheet.getRange(1,1,targetSheet.getLastRow()).getValues(); //returns all student names listed in first column of targetsheet
    var studentRow = findIndex(columnValues, studentName)+1;  //returns the rownumber where studentName was found
    var ResultInRow = col2row(sourceSheet.getRange(5,4,sourceSheet.getLastRow()).getValues()); //transpose the column data to row data
  
   targetSheet.getRange(studentRow,2,1,sourceSheet.getLastRow()).setValues(ResultInRow); //select cellrange and fill with the results 
  
  }
  
  function findIndex(columnValues, studentName) {
    for(var i=0, iLen=columnValues.length; i&lt;iLen; i++) {
      if(columnValues[i] == studentName) {
        return i;
      }
    }
  }
  
  
  function col2row(column) {
    return [column.map(function(row) {return row[0];})];
  } 
  
  function row2col(row) {
    return row[0].map(function(elem) {return [elem];});
  }
  </code></pre>
  
  <p>My question is actually twofold:
  First, since I'm not a coder by any measure, i'd like to know if my approach makes any sense, or if there is another--better--way of doing the same?
  Second, can you please help me out with the code i need to select the grades <em>only</em>, preferably labeled by the Grade's name (i.e. the exercise's name)?</p>