Armando Neto
Armando Neto

Reputation: 23

Want to gererate a link for a cell with parameters based on user input

How to generate a link based on parameters inputed by a user for a specific cell?

ex:

cell A1: user input is "123456" cell A1 link: www.abc.com/?id=123456

Upvotes: 0

Views: 46

Answers (2)

player0
player0

Reputation: 1

try:

=HYPERLINK("www.abc.com/?id="&A1, A1)

enter image description here

for arrayformula use:

=INDEX(IF(A1:A, HYPERLINK("www.abc.com/?id="&A1:A, A1:A), ))

enter image description here

Upvotes: 0

NightEye
NightEye

Reputation: 11184

This is the closest thing I can think of. If it is just solely generated by a formula, you can't input a text in a cell and expect it to have a different formula. So you need to have the links generated on another cells and the input on another cells

Formula:

=ArrayFormula(if(A2:A<>"",hyperlink("www.abc.com/?id="&A2:A),))

Formula:

formula

But via script, that would be possible:

Script:

function onEdit(e) {
  // if input is in "Sheet1!A2:A" range, convert to link automatically
  if(e.range.getRow() > 1 && e.range.getColumn() == 1 && e.source.getActiveSheet().getSheetName() == 'Sheet1' && e.value != null) {
    e.range.setValue('=hyperlink("www.abc.com/?id='+ e.value +'")');
  }
}

Script output:

output

Upvotes: 2

Related Questions