Names3 Google Sheet Exercise Notes

Patterned after names2.xlsm (custom functions) exercise.

  1. Open a copy of the sheet using the link.
  2. Select Tools|Script Editor.
  3. Click on the “Untitled project” field in the upper left and rename the project (“My Sheet Code”).
  4. Note that there is already a code module called “”. Show how you can use the pull-down arrow to rename, delete, or make a copy. Also show how you can use the File|New command to create a new script file.
  5. Note that there is already a blank function ready to go. Change the name to titleCase() and enter the code as follows:

function titleCase(myname) {

  var first = myname.substr(0,1);

  var rest = myname.substr(1);

  return first.toUpperCase() + rest.toLowerCase();


  1. Then write the other two functions:

function firstName(fullname) {

  var commaloc = fullname.indexOf(",");

  var first = fullname.substr(commaloc + 2);

  return titleCase(first);


function lastName(fullname) {

  var commaloc = fullname.indexOf(",");

  var last = fullname.substr(0, commaloc);

  return titleCase(last);


  1. Add formulas to cells. Done.