'Access specific cell from a range in a Google Spreadsheet

I have a spreadsheet in Google Docs. It has two sheets "projectList" and "projectListCompleted". When I change the contents of a specific column to "Completed" the code I have moves that ROW from projectList to projectListCompleted. If I go to the "Completed" sheet and change that same column to ANYTHING ELSE then it moves that ROW back to my Working Projects sheet. Well, I am trying to make the code a little more robust. I am creating a function called 'projectMover' and I want to call it and tell it was action to do... Completed, Cancelled, Active, etc. and have it make decisions based on that.

The code I use to move a project (i.e., an Active ROW) from one sheet to another is here:

function moveToNewSheet( myActiveSpreadsheet, myActiveSheet, myActiveRange, myTargetSheet )
{
  var row = myActiveRange.getRow();
  var numColumns = myActiveSheet.getLastColumn();
  var targetSheet = myActiveSpreadsheet.getSheetByName( myTargetSheet );
  var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
  myActiveSheet.getRange(row, 1, 1, numColumns).moveTo(target);
  myActiveSheet.deleteRow(row);
  // targetSheet.sort(1);
  return target;
};

This code works great. No problems.

But I'm starting on my projectMover function and hitting glitches because I don't understand the API as well as I would like. What I am trying to do is have 'projectMover' call the 'moveToNewSheet' code. This code passes back what SHOULD BE the RANGE of the moved project. I want to access COLUMN G in that range and insert the current date so that projects have a completed date. However, as you can see in my code I am not quite grasping how to access that cell.

Anyone have any ideas?

function projectMover( myActiveSpreadsheet, myActiveSheet, myActiveRange, myAction )
{

  switch ( myAction )
  {
    case "Completed":
      var myTarget = moveToNewSheet( myActiveSpreadsheet, myActiveSheet, myActiveRange, "projectListCompleted" );
      var targetCell = myTarget.getCell(1,7);
      targetCell.activate();
      targetCell.setValue( "test" );
      break;
    default:
      break;
  }

  // get targetSheet and sort it
};


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source