I have a sheet that has text entries in a particular column.
Each cell within that column has a number of words in it; I need to copy two or three of those words (various company names), based on their inherent value (not based on where they're positioned in the text string in the cell, nor based on what comes before or after them).
I want a function to copy those company names to the same row in another column in the sheet.
I'v been playing with this script, but I don't think it can cope with the variety in the inherent value, but perhaps it can and I just don't know the right way to implement it:
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [];
menuEntries.push({name: "Copy Company Name to Col J", functionName:
"fillColJ"});
ss.addMenu("Move Data", menuEntries);
}
function fillColJ() {
var s = SpreadsheetApp.getActiveSheet();
var data = s.getDataRange().getValues();
var data_len = data.length;
for(var i=0; i<data_len; i++) {
if(data[i][5] == "Company Name") {
s.getRange(i+1,10).setValue("Company Name");
}
}
}
Any help greatly appreciated!
String
methods, and also itsArray
methods. Both support accessing values inside the whole. - tehhowch