1

I have tried to write a custom function in google sheets.

I tried to create a function to joint the content of two cells. It works for text, however it does not work if the text contains a web-link (URL). The link is removed.

The code

function combine(...theArgs) {
  var result ="";
  var is_first = true;
  theArgs.forEach( function (value, index){
    if (! is_first) {
      result += "\n\n";
    }
    is_first=false;
    result += value;
  });
  return result;
}

Usage =combine(ref, ref) e.g. =combine(a1,b1)

I tried to use =hyperlink(url,text), this can combine the text and link from different cells, so I then tried =hyperlink(url1, text1) & hyperlink(url2, text2). The & is demoting the link to text (removes the url).

Acceptable answers: - How to get a custom function to work. - Use of built in function. - Something else that has the same effect.

1 Answer 1

1

It don't think that it's possible to do what you are looking to do with a custom function, as in order to keep the hyperlinks, you will need to set the cell content by using Class RichText which, as far as I know, is not a supported data type for custom functions.

The supported data types for custom function output are string, number, boolean, Date and Array of any of the mentioned data types.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.