I'm looking to pull email addresses from one column and put them in another column. The only thing I am struggling with at the moment is that this needs to be done based on whether the data in two other columns is the same.
I have the names of the companies in one column and the email addresses in the next. I am copying in the company names from a separate spreadsheet where it is not in the same order. I would like to be able to populate Column A with the email addresses based on if the company name is the same but I'm currently struggling to work out how this is possible.
Here is a link as to an example of what I mean.
I think I am way, way off with my code at the moment but here is what I have.
function pullEmails() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var startRow = 2;   var numRows = 2;
  var dataRange = sheet.getRange(startRow, 1, numRows, 5)   
  var data = dataRange.getValues();
  for (i in data) {
    var row = data[i];
    var showname1 = row[1];
    var showname2 = row[3];
    var values1 = sheet.getRange("B2:B100").getValues();
    var values2 = sheet.getRange("D2:D100").getValues();
    if (showname1=showname2){
      sheet.getRange("A2").setValue(sheet.getRange("E2").getValues());     
    }     
  } 
}
Which doesn't do what I need. Any help or pointers would be much appreciated! A very basic user at the moment so still sort of working in the dark!
 
     
    