jakkyjack

URLEXTRACT()

Mar 9th, 2022 (edited)
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Returns a flat array of URLs from hyperlinked text given a range of cells as a string.
  3.  * @param {string} the Range as a string you wish to get the ULS of including sheet name
  4.  * @return A flat array of raw URLs.
  5.  * @customfunction
  6.  */
  7. function URLEXTRACT(range_string) {
  8.   let range = SpreadsheetApp.getActive().getRange(range_string);
  9.   let richTextValues = range.getRichTextValues().flat()
  10.   let results = richTextValues.map(item => {return item.getLinkUrl()}).filter(item => {return item != null})
  11.   return results
  12. }
Add Comment
Please, Sign In to add comment