Incorporate hyperlink and link in script for Google spreadsheet

陌路散爱 提交于 2020-03-25 16:04:05

问题


I am currently trying desperately to include a hyperlink in my script that, after executing the script, the hyperlink as it is here should be placed in cell C16. The same would be for C17-C19 and in G19 again.

function AlteFahrerdatenLeeren(){ 
  var sheet=SpreadsheetApp.getActiveSheet(); 
  var destination="C7:C15"; 
  sheet.getRange(destination).setValue(""); 
  var sheet1=SpreadsheetApp.getActiveSheet(); 
  var destination="C20"; 
  sheet1.getRange(destination).setValue(""); 
  var sheet2=SpreadsheetApp.getActiveSheet(); 
  var destination="G6:G7"; 
  sheet2.getRange(destination).setValue(""); 
  var sheet3=SpreadsheetApp.getActiveSheet(); 
  var destination="G9"; 
  sheet3.getRange(destination).setValue(""); 
  var sheet4=SpreadsheetApp.getActiveSheet(); 
  var destination="G11:G17"; 
  sheet4.getRange(destination).setValue(""); 
  var sheet5=SpreadsheetApp.getActiveSheet(); 
  var destination="G20"; 
  sheet5.getRange(destination).setValue(""); 
  var sheet5=SpreadsheetApp.getActiveSheet(); 
  var destination="N16:N17"; 
  sheet5.getRange(destination).setValue(""); 
  var sheet6=SpreadsheetApp.getActiveSheet(); 
  var destination="Q10:R10"; 
  sheet6.getRange(destination).setValue(""); 
  var sheet7=SpreadsheetApp.getActiveSheet(); 
  var destination="S6"; 
  sheet7.getRange(destination).setValue(""); 
  var sheet8=SpreadsheetApp.getActiveSheet(); 
  var destination="O22:S32"; 
  sheet8.getRange(destination).setValue(""); 
  var sheet9=SpreadsheetApp.getActiveSheet(); 
  var destination="G35:S50"; 
  sheet9.getRange(destination).setValue(""); 
  var sheet10=SpreadsheetApp.getActiveSheet(); 
  var destination="B53:S91"; 
  sheet10.getRange(destination).setValue(""); 
  **var SS=SpreadsheetApp.getActiveSheet(); 
  var sheet=ss.getRange(C16).setValue(HYPERLINK("https://erfurter-fernverkehrs-logistic.de/";"Neu"));** 
}

Furthermore what I ask myself. Is there a way to test a link in a script that he can get the last missing data from C20 via a button and then link to the website?

Help is very much appreciated. I'm completely new to the area.

enter image description here As here in the pictures, the ticks in the boxes are inside. But with my script I want to remove the tick so that there are only the empty boxes. And the range would be: K22: L32.

Sorry for the bad translation. Since I can't speak English myself, I had to do it via Google Translate.


回答1:


You have to use setFormula instead of setValue:

sheet.getRange('C16').setFormula('=HYPERLINK("https://erfurter-fernverkehrs-logistic.de/";"Neu")');

Also, you don't need to repeat this every time. You only have to do it once:

var sheet=SpreadsheetApp.getActiveSheet();

Reference:

  • Range.setFormula(formula)


来源:https://stackoverflow.com/questions/60295778/incorporate-hyperlink-and-link-in-script-for-google-spreadsheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!