Use this formula (Where A2 is your url without the https)
=IF(REGEXMATCH(A1,"^https?:\/\/[\w\.]*"),A1,"https://" & A1)
Edit
function onEdit(e) {
const s = SpreadsheetApp.getActive();
const cell = e.range;
const url = cell.getValue();
if (/^(?<!https?:\/\/)[\w\.]+\.\w+/.test(url)) {
cell.setValue("https://" + url)
}
}
This uses a weird Regex syntax that I'm amazed actually works. Just slap this onto your Appscript editor then give it permission. If you input a url without the http://
or https://
, then it will append an https://
to the url.
Edit#2
function onEdit(e) {
const s = SpreadsheetApp.getActive();
const cells = e.range;
const urlList = cells.getValues();
for (let i = 0; i < urlList.length; i++) {
for (j = 0; j < urlList[i].length; j++) {
const url = urlList[i][j];
if (/^(?<!https?:\/\/)[\w\.]+\.\w+/.test(url)) {
cells.getCell(i+1,j+1).setValue("https://" + url)
}
}
}
}
This should deal with copy-pasting different values. I still don't understand why you need to append urls with https:// though. As for your other comment, do you have a really big dataset? Is it possible for you to just copy and paste the values onto the same cells? Sorry I took a while to getting back to you.