Forum Discussion

Jeff_Hunt's avatar
Jeff_Hunt
Copper Contributor
Aug 15, 2023
Solved

Need a script to find the last cell-copy, paste as value, then format as text on another sheet.

Here is a greatly simplified version of a script I am trying to run:   In this example I have it going to a single column sheet that will work fine.  It may work better (I need this for a Pow...
  • SergeiBaklan's avatar
    SergeiBaklan
    Aug 16, 2023

    Jeff_Hunt 

    Perhaps like

    function main(workbook: ExcelScript.Workbook) {
    
     const value =
      workbook
        .getWorksheet("Sheet1")
        .getUsedRange()
        .getLastCell()
        .getValue()
        .toString()
    
      const targetCell =
        workbook
          .getWorksheet("Sheet2")
          .getUsedRange()
          .getLastCell()
          .getOffsetRange(1, 0)
    
      targetCell
        .setNumberFormats([["@"]])
    
      targetCell
        .setValue(value)
    
        
    
    }

Resources