I am rephrasing my original question to make it more intelligible.
I put spaces between "https" below because StackOverflow would not allow me to enter the actual URL.
Of course I could enter the text "apple" in cell A1 and then add a link from A1 to foo.com/Apple
so that I would end up with [Apple](h t t p s://foo.com/Apple) in A1. However, I want that done automatically.
In other words, I want to...
- Go to a cell, and then
- type "apple" on my keyboard, and then
- press enter, and then
- instead of merely seeing "apple" in plain text, I actually I want to see
- "apple" hyperlinked to
foo.com/Apple
like this [Apple](h t t p s://foo.com/Apple).
CodePudding user response:
try:
=INDEX("foo.com/"&B2:B3)
CodePudding user response:
To get what you want you can use Google Apps Script. Adding a trigger that fires every time column A is edited, getting the entered value and combining it with the =HYPERLINK(url, link_label)
function, should get what you need.
- Open the Google Apps Script editor,
Tools>Script Editor
- Add the following code
function onEdit(e) {
// Check the edit is in column A
if(e.range.getColumn()==1){
// Get the values from the onEdit
let cell = e.range.getA1Notation()
let value = e.value
let ss = e.source
// Adding as HYPERLINK Formulas
ss.getRange(cell)
.setFormula(`=HYPERLINK("https://example.com/${value}","${value}")`)
}
}