Calculated in-document hyperlink - hyperlink

I would like to create a calculated hyperlink that will target a cell within the same document. Insert > Hyperlink allows this option and uses the string #Sheet1!A1, for the Cell A1 on Sheet1, for example.
Is there a way to express this feature as a formula such that it can create the hyperlink based on the result of a calculation?

Yes, there's the HYPERLINK() function:
=HYPERLINK(CONCATENATE("#Sheet1!",T(E2)),"Test")
NB: when working with other language settings then "English (USA)", OOo might require other argument separators (for example: with "German (Germany)", semicolons instead of commas are required).
Split on multiple lines for readability:
=HYPERLINK(
CONCATENATE(
"#Sheet1!",
T(E2)
),
"Test"
)
It will insert a hyperlink, with the target depending on the content of the cell E2. Using the T() function, the Sheet could be set dynamically, too. In my example, E2 could have the value of "A1", resulting in a hyperlink pointing to #Sheet1!A1.
EDIT: Here's a screenshot of a hyperlink with target sheet, target cell and hyperlink text set dynamically:
using this formula:
=HYPERLINK(CONCATENATE("#",T(D1),"!",T(D2)),T(D3))

Related

How can I get this formula to grab values between the commas?

Here is a screenshot of and a link to my test spreadsheet. It makes the requirements very clear:
https://docs.google.com/spreadsheets/d/1rZr2zHaSkff9SFpwpx83_4TawruotA1jhOKqW6uYDz0/edit?usp=sharing
The formula I have come up with is very close to what I need, but "linkText" is a placeholder for the value of the array item. Here is my formula:
=if(A2="","","<a href='https://samplewebsite.com/search?q=" & trim(lower(substitute(A2,",","'>linkText</a>, <a href='https://samplewebsite.com/search?q="))) & "'>linkText</a>")
try:
=index(join(","&char(10), SUBSTITUTE($B$1, "linkText", split(A3, ","))))
Drag down to column.
Result:
First using SPLIT to split the strings between comma from the column A. Then using SUBSTITUTE to find the string "linkText" from the text in B1 and replace it with the strings from the returned strings from the split function. Then joining them all together.
NOTE: Just keep the reference string in a fixed cell in your sheet. <a href='https://samplewebsite.com/search?q=linkText'>linkText</a> to be used in the formula. As seen in above screenshot it is fixed in cell B1.
Alternate Solution using ArrayFormula:
You can also use it with arrayformula so you only have to put it in the first row and no need to drag down the formula to the column, it will automatically be expanded down just make sure to clear the cells below or it will throw an error.
=arrayformula(regexreplace(substitute(transpose(query(transpose(IF(IFERROR(SPLIT(A2:A, ","))<>"", "♦<a href='https://samplewebsite.com/search?q="&SPLIT(A2:A, ",")&"'>"&SPLIT(A2:A, ",")&"</a>", )),,9^9)), "♦", char(10)), "^\s", ""))
Result:
You may also have a look in below references for more information.
References:
SUBSTITUTE
SPLIT
JOIN
Comma separated list into matched columns pairings

preserving hyperlink from cell when doing REGEXREPLACE in google sheets

In Google Sheets, doing =REGEXREPLACE(B10,".*\. ","") correctly turns "1. a" to "a" but the hyperlink from B10 cell is gone, is there a way to preserve this link automatically, or any way to transfer the link to the new cell automatically?
It seems that you have used Insert Hyperlink menu to insert the hyperlink in B10, copied B10 to C10 (preserved the hyperlink), then replaced C10 with =REGEXREPLACE(B10,".*\. ",""), which removed the hyperlink.
You could try using HYPERLINK function to explicitly define hyperlinks, like this:
B10: =HYPERLINK("https://google.com","1. a")
C10: =HYPERLINK("https://google.com",REGEXREPLACE(B10,".*\. ",""))

Google Sheets Match Any Text

In Google Sheets, I have 2 columns (A and B) of text and I'm trying to set up conditional formatting to identify partial duplicates for when these 2 criteria are both met:
Text in A exactly matches with any other cell in A
and
Any of the individual words in cell B match any of the words in any other cell in B
So, if A2 = "target.com" and B2 = "Big Bonus"
I want it to flag any other cells where A = "target.com" and B = "Bonus Donuts" or "Biggest Exciting Bonus Ever" (because "Bonus" is identified as the duplicate) or "Exciting Big Day" (because "Big" is identified as the duplicate). I need it to be case-agnostic.
Nothing I have tried has even come close to working, so I won't include any of it here.
Sample Data: https://docs.google.com/spreadsheets/d/1DO-0uJRf6MOJ7fJiza5MAmFNIqpCwJ4WMH28j6wp22w/edit#gid=0
I've added a new sheet ("Erik Help") to your sample spreadsheet, with the following custom CF rule applied to the range A3:B ...
=AND($A3=$A$1, REGEXEXTRACT(LOWER($B3),SUBSTITUTE(TRIM(LOWER($B$1))," ","|")))
$A3=$A$1 should be self-explanatory.
For the rest, you see I used LOWER to make the comparisons caps-agnostic. I applied TRIM, just in case you accidentally added any spaces into the B1 string and then just replaced remaining spaces with the pipe symbol, which is interpreted by REGEXEXTRACT as OR.
If you don't want partial word matching (Big in Biggest), try this in the conditional custom formula:
=and($A3=$A$1, regexextract(" "&lower($B3)&" "," "&substitute(lower($B$1)," "," | ")&" "))

How can I use conditional formatting to compare against a dynamic worksheet?

I am trying to use conditional formatting to compare the value of one cell against another in a dynamically referenced worksheet while using a dynamic cell reference and highlight the cell whenever the values do not match.
I have created a master sheet containing a cell with the name of the worksheet I wish to reference. This cell will be updated periodically with the name of the relevant worksheet. I am able to write a formula that correctly returns the value I wish to compare, but when I enter this expression in the conditional format rule (format cells if is not equal to) I am given a red outline with the message "Invalid formula".
I have tried various combinations such as using a custom formula and using (current cell = (formula here)) and while I am not given an error, it still does not work as intended.
I am comparing the value of cell C2 in worksheet 4719 to cell C2 in worksheet 4717. A cell in a worksheet called Mastersheet contains the entry "4717" in B1, and this is the cell that will be periodically changed to something like 4717 for example.
The formula that is able to successfully return the value I am after is =indirect(Mastersheet!B1&"!"&"C2") but I was only able to accomplish this by putting the "C2" reference in quotation marks, which is not dynamic and thus would have to be manually changed to work for any of the other values in column C.
I expect cell C1 in worksheet 4719 to turn green as the value there is different from cell C1 in worksheet 4718.
I made a publicly viewable copy of my Google sheet if my explanation does not make enough sense https://docs.google.com/spreadsheets/d/1s0oaGas46akmGV7hapnDOdhndcWudyq239kmCrLnt3U/edit?usp=sharing
try it like this:
=INDIRECT(Mastersheet!$B$1&"!"&ADDRESS(ROW(C2), COLUMN(C2), 4))
this can be used in Conditional formatting, however, referenced sheet cant be fully active so:
=INDIRECT(INDIRECT("Mastersheet!B1")&"!"&ADDRESS(ROW(C2),COLUMN(C2),4))
this can be further moded so the B1 would be dynamic too:
=INDIRECT(INDIRECT("Mastersheet!"&ADDRESS(ROW(B1),COLUMN(B1)))&"!"&
ADDRESS(ROW(C2),COLUMN(C2),4))=19

Google Sheets Query referencing a cell's text

When I perform this function, it works:
=Query(CRM!1:1085,"Select B where D contains 'FirstName LastName' ",4)
When I perform this one, where B31 is where the text "FirstName LastName" is located in the sheet, the output is only ONE of the many results:
=Query(CRM!1:1085,"Select B where D contains '&B31&' ",4)
I want to be able to use the cell rather than write the quoted text in the formula. This is because I need to quickly replicate the formula for many different values. Also because it needs to be automated in case of changes in the source.
B31 is interpreted as literal string, when you use just 'B31'. You need to use double quotes along with single ones and concatenate:
'"&B31&"'

Resources