Google Sheets: Iterate rows/columns, Compare two cells, Clear contents 4 cells

I have a formula I made it almost does what I want but instead of just clearing the four cells in the row where the two cells are different it clears all the four cells for each row.
I know I have to do a for loop but it has me confused.
Here is whatI have so far:

 function compareClear() {
       var ss = SpreadsheetApp.getActiveSpreadsheet();
       var sheet = ss.getSheetByName("Sheet1");
       var firstdate = sheet.getRange("E3:E").getValues();
       var secdate = sheet.getRange("AG3:AG").getValues();

        if(firstdate != secdate){
              SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getRange("AH3:AH").clearContent();
         }
  } 

Right now I have it only clearing one cell of content but it works yet like I said it clears all AH cells not just the row which the first two cells do not match. I would like to eventually clear contents of AH, AI, AJ, AK.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.