1
votes

As a default Column B is equal to Column U. I'd like to find a macro that copies the value in Column U (e.g. U2) and pastes it as a value in the same cell (U2) if a value is inputted into cell C3 (one row below the U2 cell). Please see the example below, where if I enter GHI123 in cell C3, CD must be copied and pasted in cell U2.

https://docs.google.com/spreadsheets/d/1wZFh8IW6SLkOxNBSyUaDapOnMm2cJwxjZ7KFA79MKnw/edit#gid=0

1
basically this: =ARRAYFORMULA(IF(LEN(C1:C), B1:B, )) via scriptplayer0

1 Answers

0
votes

You can achieve this with the following Apps Script

function onEdit(e) {
  var row = e.range.getRow();
  var column = e.range.getColumn();

  if (column == 3){
    cellToEdit = 'U' + (row - 1);
    dataToPaste = SpreadsheetApp.getActiveSheet().getRange(cellToEdit).getDisplayValue()
    SpreadsheetApp.getActiveSheet().getRange(cellToEdit).setValue(dataToPaste);

}

The getDisplayValue() method allows you to read the displayed value of a cell after any script evaluation. You can find the reference for this method here.