Created
June 16, 2014 13:09
-
-
Save johnwesonga/7bffdd5e7a446e178b89 to your computer and use it in GitHub Desktop.
Apps Script to copy data from one column to multiple columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function copyData() { | |
var mySheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); | |
var range = mySheet.getDataRange(); | |
var firstNameCell = mySheet.getRange('A1'); | |
var lastNameCell = mySheet.getRange('B1'); | |
var row = 1; | |
//skip the header column | |
var dataRange = range.offset(1, 0, range.getNumRows()-1).getValues(); | |
for (i = 0; i < dataRange.length; i++){ | |
if (dataRange[i][2]){ | |
firstNameCell.offset(row, 0).setValue(dataRange[i][2].split(" ")[0]); | |
lastNameCell.offset(row, 0).setValue(dataRange[i][2].split(" ")[1]); | |
} | |
row++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment