function myFunction() {
SpreadsheetApp.getActive().getRange('Data!A1').setValue('=importdata("URL here")')
}
function convertToImage() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var range = sheet.getDataRange();
// I was trying to change this number from 3 to 10, and it doesn't let me.
var colnum = 3; // assuming column C; change to another column number
var cell;
var values = range.getValues();
for (var i=0; i<values.length; i++) {
if (values[i][colnum-1]) {
cell = range.getCell(i+1, colnum);
cell.setFormula('=image("'+values[i][colnum-1]+'")')
}
}
}
I modified the code like this and saved it no problem
function convertToImage() {
const ss = SpreadsheetApp.getActive;
const sh = ss.getActiveSheet();
const rg = sh.getDataRange();
const col = 4;
const vs = rg.getValues();
for (let i = 0; i < vs.length; i++) {
if (vs[i][col - 1]) {
rg.getCell(i + 1, col).setFormula('=image("' + vs[i][col - 1] + '")');
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.