Copying the value of a cell in Google Sheets only if a different cell is not empty

If you want to filter out blank cells in Excel, the accepted answer is effective. However, it may not work if the cells contain formulas that evaluate to blank. In this case, ISTEXT will return TRUE and the blanks won’t be filtered out. To address this issue, you could use the default check for ISBLANK. Alternatively, you could follow Solution 1 and filter out rows with blank cells in column D. Just keep in mind that the second argument would also need to be filtered to ensure the ranges are the same length.


Begin by utilizing a script that is alike to this one.

function copyVals() {
  let ss = SpreadsheetApp.openById("ID");
  let sheet1 = ss.getSheetByName("Sheet1");
  let sheet2 = ss.getSheetByName("Sheet2");
  let colA = sheet1.getRange('A:A');
  if (!colA.isBlank()) {
    let valToPaste = sheet2.getRange(1,1).getValue();

To ensure that the desired column is not blank, the


function is utilized. If the verification is successful, the value from


is copied into


using the



  • You may need to add a


    loop, depending on your exact needs.

  • Since you mentioned you are using a form, you may want to check Apps Script triggers.

  • The isBlank() method of the Range class in Apps Script.

Frequently Asked Questions