To integrate this functionality into your script editor, simply follow these steps. First, insert the code provided into your script editor, then save and execute it. Make sure to approve any popups that may appear during execution. Next, navigate to the "Edit" option in the script editor menu and choose 'current project's triggers'. Configure the trigger settings to run this function on a daily basis at the desired time.
function refreshData() {
var ss=SpreadsheetApp.getActiveSpreadsheet()
var s=ss.getSheetByName("Sheet1")
var lr= s.getLastRow()
var data= s.getRange(1,3,lr,1).getValues()
var s1=ss.getSheetByName("Sheet2")
var lr1=s1.getLastRow()
var dte=s1.getRange(lr1+1, 3, 1, 1).setValue(new Date())
var lr1=s1.getLastRow()
var setdte=s1.getRange(lr1+1, 3, data.length, 1).setValues(data)
var clr=s.getRange("C1").clearContent()
var cell=s.getRange("C1").setFormula('=IMPORTXML("https://www.avanza.se/aktier/om-aktien.html/5447/abb-ltd\",\"//dl[@class=\'border XSText rightAlignText noMarginTop highlightOnHover thickBorderBottom noTopBorder\']//dd\")')
}
This code snippet enhances the functionality by creating a copy in Sheet2 with a timestamp for each entry added after the last one.