This question already has answers here:
How to add multiple links in excel cell?
(2 answers)
Closed 1 year ago.
TLDR:
Unknown error appears if you have a formula constructed like this:
IFNA(Link1;Link2)
However, below example works which is basically the same thing,
A1: Link1
A2: IFNA(A1;Link2)
Edit: Formula in URLTEXT when IFNA function contains two LINK functions might be the culprit.
Any ideas why this might be?
Hi,
i am trying to make a dynamic link on cell C1. From a search string it looks through column A to find the search string on cell A1. I have added an IFNA function that checks if entery is missing in column A. If this happens then it looks for the search string A1 again but in column B.
The problem and unknown error,
when it matches with a string on column B then the dymanic link throws an error:
(Rough translation from swedish)
"file:///(long path)/ABCD%3F" is not an absolut URL that can be sent to an external program be opened."
However, each dynamic link works seperatly. It is when i combine them with the IFNA that this problem occur.
It seems like the constructed link is equal to the URLTEXT from the first lookup when it is supposed to be the row number from the second lookup.
I suspect this is the reason the link fails. I might be wrong though and i cant see why this would happen.
When breaking down the components into smaller parts all looks good:
Picture showing the setup and component breakdown
Picture showing formulas
Below is the setup for replicating this issue. Formulas and their belonging cells:
A1 = "ABC"
A3 = "acol"
A4 = "AB"
A5 = "CD"
B3 = "bcol"
B3 = "ABCD"
B4 = "CDEF"
C3 = "acode"
D3 = "bcode"
Renamed cells:
lookup_search_cell = A1
lookup_code_arr = A4:D5
translated_lookup_search_cell = B1
lookup_acode_col = C4:C5
lookup_bcode_col = D4:D5
B1:
=CONCATENATE(,
IF(CODE(MID(UPPER(A1),1,1))=0,CODE(MID(UPPER(A1),1,1))),
IF(CODE(MID(UPPER(A1),2,1))=0,CODE(MID(UPPER(A1),2,1))),
IF(CODE(MID(UPPER(A1),3,1))=0,CODE(MID(UPPER(A1),3,1))),
IF(CODE(MID(UPPER(A1),4,1))=0,CODE(MID(UPPER(A1),4,1))))
C1:
=IF(lookup_search_cell="","Enter🔎",
IFNA(
IFNA(
LINK("#sheet1.$A$" &
MATCH(translated_lookup_search_cell&"*",lookup_acode_col,0)+3 & ":" & "$B$" &
MATCH(translated_lookup_search_cell&"*",lookup_acode_col,0)+3,
IFERROR(
INDEX(lookup_code_arr,
MATCH(translated_lookup_search_cell&"*",lookup_acode_col,0),1
)&"?","Cant find acol entery"
)
),
LINK("#sheet1.$A$"&
MATCH(translated_lookup_search_cell&"*",lookup_bcode_col,0)+3 & ":" & "$B$" &
MATCH(translated_lookup_search_cell&"*",lookup_bcode_col,0)+3,
IFERROR(
INDEX(lookup_code_arr,
MATCH(translated_lookup_search_cell&"*",lookup_bcode_col,0),2
)&"?","Cant find bcol entery"
)
)
),"Cant find entery"
)
)
C4:
=CONCATENATE(,
IF(CODE(MID(UPPER(A4),1,1))=0,CODE(MID(UPPER(A4),1,1))),
IF(CODE(MID(UPPER(A4),2,1))=0,CODE(MID(UPPER(A4),2,1))),
IF(CODE(MID(UPPER(A4),3,1))=0,CODE(MID(UPPER(A4),3,1))),
IF(CODE(MID(UPPER(A4),4,1))=0,CODE(MID(UPPER(A4),4,1))))
C5:
=CONCATENATE(,
IF(CODE(MID(UPPER(A5),1,1))=0,CODE(MID(UPPER(A5),1,1))),
IF(CODE(MID(UPPER(A5),2,1))=0,CODE(MID(UPPER(A5),2,1))),
IF(CODE(MID(UPPER(A5),3,1))=0,CODE(MID(UPPER(A5),3,1))),
IF(CODE(MID(UPPER(A5),4,1))=0,CODE(MID(UPPER(A5),4,1))))
D4:
=CONCATENATE(,
IF(CODE(MID(UPPER(B4),1,1))=0,CODE(MID(UPPER(B4),1,1))),
IF(CODE(MID(UPPER(B4),2,1))=0,CODE(MID(UPPER(B4),2,1))),
IF(CODE(MID(UPPER(B4),3,1))=0,CODE(MID(UPPER(B4),3,1))),
IF(CODE(MID(UPPER(B4),4,1))=0,CODE(MID(UPPER(B4),4,1))))
D5:
=CONCATENATE(,
IF(CODE(MID(UPPER(B5),1,1))=0,CODE(MID(UPPER(B5),1,1))),
IF(CODE(MID(UPPER(B5),2,1))=0,CODE(MID(UPPER(B5),2,1))),
IF(CODE(MID(UPPER(B5),3,1))=0,CODE(MID(UPPER(B5),3,1))),
IF(CODE(MID(UPPER(B5),4,1))=0,CODE(MID(UPPER(B5),4,1))))
Sorry, i think this was a repost, found answer here.
How to add multiple links in excel cell?
This question can be deleted. If true then thanks to Didier for the information.
Here is another solution instead if anyone find it interesting,
=OM(lookup_search_cell=""
;
"Enter🔎"
;
LÄNK("#sheet1.$A$"&
OMSAKNAS(
PASSA(translated_lookup_search_cell&"*";lookup_acode_col;0)+3&":"&"$B$"&
PASSA(translated_lookup_search_cell&"*";lookup_acode_col;0)+3
;
PASSA(translated_lookup_search_cell&"*";lookup_bcode_col;0)+3&":"&"$B$"&
PASSA(translated_lookup_search_cell&"*";lookup_bcode_col;0)+3
)
;
OMSAKNAS(
INDEX(lookup_code_arr;
PASSA(translated_lookup_search_cell&"*";lookup_acode_col;0);1
)&"?"
;
INDEX(lookup_code_arr;
PASSA(translated_lookup_search_cell&"*";lookup_bcode_col;0);2
)&"?"
)
)
)
Conclution, you cant have multiple links in the same cell but you can mold the one and only link to what you want it to be.
Related
The function I expected
some_function(original_text, "search_text", "replacement_text")
The value of the second & third parameters will be multiple characters. For example. The result will replace the character based on the location of the character at the second & third parameters
some_function("9528", "1234567890", "abcdefghij")
1 -> a
2 -> b
3 -> c
...
8 -> h
9 -> i
0 -> j
The result of some_function will be iebh. The nested SUBSTITUTE function can archive the goal but I hope to compact the complexity.
The way you described your requirement is best written out via REDUCE(), a lambda-related helper function and recently announced to be in production:
=REDUCE("9528",SEQUENCE(10),LAMBDA(x,y,SUBSTITUTE(x,MID("1234567890",y,1),MID("abcdefghij",y,1))))
Needless to say, this would become more vivid when used with cell-references:
Formula in A3:
=REDUCE(A1,SEQUENCE(LEN(B1)),LAMBDA(x,y,SUBSTITUTE(x,MID(B1,y,1),MID(C1,y,1))))
Another, more convoluted way, could be:
=LET(A,9528,B,1234567890,C,"abcdefghij",D,MID(A,SEQUENCE(LEN(A)),1),CONCAT(IFERROR(MID(C,FIND(D,B),1),D)))
Or, as per the sceenshot above:
=LET(A,A1,B,B1,C,C1,D,MID(A,SEQUENCE(LEN(A)),1),CONCAT(IFERROR(MID(C,FIND(D,B),1),D)))
Function Multi_Replace(Original As String, Search_Text As String, Replace_With As String) As String
'intEnd represents the last character being replaced
Dim intEnd As Long: intEnd = WorksheetFunction.Min(Len(Search_Text), Len(Replace_With))
'necessary if Search text and replace text are different lengths;
Dim intChar As Long 'to track which character we're replacing
'Replace each character individually
For intChar = 1 To intEnd
Original = Replace(Original, Mid(Search_Text, intChar, 1), Mid(Replace_With, intChar, 1))
Next
Multi_Replace = Original
End Function
Maybe simpler if you do not have lambda yet: =TEXTJOIN(,,CHAR(96+MID(A1,SEQUENCE(LEN(A1)),1)))
*Note that this will not return 0 as the expected result.
Let's say you have a list of countries in column A and aim to replace all the abbreviations with the corresponding full names. you start with inputting the "Find" and "Replace" items in separate columns (D and E respectively), and then enter this formula in B2:
=XLOOKUP(A2, $D$2:$D$4, $E$2:$E$4, A2)
Translated from the Excel language into the human language, here's what the formula does:
Search for the A2 value (lookup_value) in D2:D4 (lookup_array) and return a match from E2:E4 (return_array). If not found, pull the original value from A2.
Double-click the fill handle to get the formula copied to the below cells, and the result won't keep you waiting:
Since the XLOOKUP function is only available in Excel 365, the above formula won't work in earlier versions. However, you can easily mimic this behavior with a combination of IFERROR or IFNA and VLOOKUP:
=IFNA(VLOOKUP(A2, $D$2:$E$4, 2, FALSE), A2)
Let's say for example that I have these number in diffetent cells : 5 , 3 , 2. In different cell I type "=SUM(cells of my numbers)". So my question is : is it possible that result will be shown as "5 + 3 + 2" instead of just "10"?
BTW: I know that it's rather strange question.
You can use TEXTJOIN
=TEXTJOIN(" + ",TRUE,A1:C1)&" = "&SUM(A1:C1)
As mentioned via comment & assuming A1:A3 contain the desired value, the formula :
=A1&" + "&A2&" + "&A3
should do what you need. It is not a strange question. Maybe the (technically closer) is it possible that cell to display.. term is closer to what the technical communities here have in mind. (I'm not complaining.. english is hard on me too).
*Just fyi, "show calculation step" is the use of [ (select cell with formula) > Formula > Evaluate ] function in excel. It may be the reason this question is misunderstood. (^_^)\
How can I use a formula in MS Excel to reverse a comma separated sting in row? The number of values are not always same so some rows have 3, 4 and some only one element.
So the output looks like following image
If you have Office 365 Excel then use This array formula:
=TEXTJOIN(",",,TRIM(MID(SUBSTITUTE(A2,",",REPT(" ",99)),((LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1)-ROW($XFD$1:INDEX(XFD:XFD,LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1)))*99+1,99)))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
If one does not have Office 365 Excel then vba will probably be the only choice.
Sloppy UDF solution:
Function REVERSESTRING(original As Range, delim As String)
Dim i As Long, reversed As String, arr As Variant
arr = Split(original.Value, delim)
For i = UBound(arr) To 0 Step -1
reversed = reversed & arr(i) & ","
Next i
REVERSESTRING = Left(reversed, Len(reversed) - 1)
End Function
A pure single-cell formula works in Excel 365; with that version there is no need for special array calculation entry, VBscripts, or helper columns:
Procedure
Make the following table in Excel:
Add column headings
Select headings, and press the Table icon on the Insert ribbon tab
Copy formula 1 & 2 below into the appropriate columns
Original | # | Reversed
---------+-----+-----------
| {1} | {2}
Place the string you would like to reverse in the first column.
Details and customization
'Original' column
(holds the delimited string value you wish to process)
Place your source data in this column (as seen in the example images)
'#' column
(counts number of items in delimited cell)
Note: (this column is completely optional; it simply shows the number of items in the original column)
{1} <- replace with formula #1:
=LET(
existingDelimiter, ","
, originalValue, [#[Original]]
, SUM(
LEN(originalValue)
- LEN(
SUBSTITUTE(
originalValue
, existingDelimiter
, ""
)
)
)
+1
)
(Note: If your list uses a delimiter other than a comma or if the first column of your table will have a different name, edit the above as appropriate using the same instructions given for formula #2 below.)
'Reversed' column
(reverses order of delimited items in list; optionally changes delimiter)
{2} <- replace with formula #2:
=LET(
existingDelimiter, ","
, newDelimiter, ","
, originalValue, [#[Original]]
, SUBSTITUTE(
ARRAYTOTEXT(
LET(
list,
IFERROR(
FILTERXML(
"<t><s>"
& SUBSTITUTE(
originalValue
,existingDelimiter
,"</s><s>"
)
& "</s></t>"
, "//s"
)
,""
)
,SORTBY(
list,
SEQUENCE(
ROWS(list)
,1
,ROWS(list)
,-1
)
)
)
,0
)
, ", "
, newDelimiter
)
)
Adjust the formula for what you are trying to accomplish by changing the values for existingDelimiter, newDelimiter, and originalValue, as necessary.
A. To reverse a comma-separated string, use the formula as written:
existingDelimiter, ","
, newDelimiter, ","
Example:
B. To reverse DNS names, replace the comma with a period in the definitions for existingDelimiter and newDelimiter:
existingDelimiter, "."
, newDelimiter, "."
This can be very useful for reverse DNS names (aka Java class names / Universal Type Indicators (UTIs) / etc.)
Example:
Replace "Original" in [#[Original]] with the name of your first column, if different.
A. If using just a single cell for input instead of a table column, replace [#[Original]] with the reference to that cell (e.g. B2):
, originalValue, B2
Example:
Explaination of the "Reversed" column formula:
By manually converting to XML, we can use the FilterXML function, which converts the data to an array.
Having the data in an array allows the use of the SortBy function.
SortBy reverses the array by using a helper array created with the Sequence function.
Finally, the ArrayToText functions converts this (now reverse-ordered) array back to a text string that will fit in a single spreadsheet cell.
This is what allows us not to need a loop, helper columns, or VBScript.
Bonus column
To extract a specific term from a list, use the following formula in another table column:
(Change the number in termNumber to the desired value):
=LET(
existingDelimiter, ","
, originalValue, [#[Original]]
, termNumber, "[2]"
, IFERROR(
FILTERXML(
"<t><s>"
& SUBSTITUTE(
originalValue
, existingDelimiter
, "</s><s>"
)
& "</s></t>"
, "//s"
& termNumber
)
, ""
)
)
Example:
Other notes
Needed:
Excel 365 (for at least FilterXML and Let functions, and dynamic arrays) (*)
It might work with other versions but I have not tested those. Please note in the comments if you notice other or future versions (e.g. Excel 2022) work with this.
Not needed:
dynamic array entry
VBscript
macro-enabled files
(*) This can be done without the Let function, but using Let allows the calculation to be edited / repurposed with less chance for user error.
Note: When the Lambda function is released (hopefully later in 2021) then this all can be wrapped up in a named worksheet function
Bonus: to edit more complex Excel formulas with code highlighting (and other features such as auto-intents and folding), try a text editor with Swift programming language support. Examples:
VSCode editor (free; cross-platform)
Until there is an Excel-specific extension available, install a Swift VSCode extension such as this: Swift language VSCode extension (it seems to work quite well to provide code highlighting and folding)
Notepad++ (free; Windows-only)
Select "Swift" from the "Language" menu
Inspired by (apologies if I've forgotten someone):
https://www.howtoexcel.org/tutorials/split-text-by-delimiter/
https://www.sumproduct.com/news/article/have-you-got-what-it-text-introducing-arraytotext-and-valuetotext
https://exceljet.net/formula/reverse-a-list-or-range
I have a column with 11k+ rows of text. Some of them look like this:
1. vc (abrev.), viscous coupling
and some may look like this:
2. manual transmission fluid, mtf (abrev.)
or even:
3. m/t (abrev.), manual transaxle, manual transmission, mt (abrev.)
My goal is simply extract "* (abrev.)" without the quotes from within the text, and place it in a new column. In the third case, it would be nice if both "m/t (abrev.)" and "mt (abrev.)" could be extracted and separated with a comma.
So far I've came up with this function
=IFERROR(IF(FIND("abrev.",C68),MID(C68,1,FIND(")",C68)),""),"")
which works in some cases, but not on everyone of them. (function was translated with http://en.excel-translator.de/translator/ because original function is in portuguese). I even tried using wildcards in the function but they don't work.
Any ideas?
Thanks.
I have a solution for you but it takes multiple columns to do it. If the data starts in cell A2, here are the formulas:
B2 = FIND("(abrev.)", A2)
C2 = IFERROR(TRIM(RIGHT(TRIM(LEFT(A2,B2-1)),FIND(" ",TRIM(LEFT(A2,B2-1))))), "")
D2 = IFERROR(FIND("(abrev.)", A2, B2+1), "")
E2 = IFERROR(TRIM(RIGHT(TRIM(LEFT(A2,D2-1)),FIND(" ",TRIM(LEFT(A2,D2-1))))), "")
F2 (your goal) = CONCATENATE(IF(LEN(C2) > 0, C2 & " (abrev.)", ""), IF(LEN(E2) > 0, ", " & E2 & " (abrev.)", ""))
Basically what it is doing is finding the phrase "(abrev.)" and then finding the space before the word before it and selecting that phrase and then putting them together again at the end.
I am trying to write a formula to include multiple criteria and can't seem to get it right.
The formula works as is however I need to include "SHOT10","SHOT20", "SH15" and "SH20"
=IF(AND(C5194="SHOT15",H5194="",I5194=""),E5194,"")
Can someone assist me with modifying the above formula?
The AND(C5194="SHOT15",H5194="",I5194="") is equivalent to saying:
C5194="SHOT15" And H5194="" And 15194=""
So what you have in VBA code is:
If C5194="SHOT15" And H5194="" And 15194="" Then
ActiveCell = E5194
Else
ActiveCell = ""
End
You can use AND( and OR( to specify different parameters.
For example, If I want to pickup 3 different values in 'A1', but make sure that 'B1' and 'C1' are blank, I can use:
=IF(AND(OR(A1="A",A1="B",A1="C"),B1="",C1=""),"True","False")
So in your case specifically:
The issue now is that I now need to also consider SHOT10, SHOT20, SH15 and SH20 as well. Meaning that if either SHOT15, SHOT10, SHOT20, SH15 or SH20 appears in C5194 and H5194 is blank and I5194 is also blank then return the value of E5194 else return blank. The key is that all the conditions must be met for the value of E5194 be returned
Your formula becomes:
=IF(AND(OR(C5194="SHOT15",C5194="SHOT10",C5194="SHOT20",C5194="SH15",C5194="SH20"),H5194="",I5194=""),E5194,"")
Edit: Shorten Using an array constant per barry houdini:
=IF(AND(OR(C5194={"SHOT15","SHOT10","SHOT20","SH15","SH20"}),H5194="",I5194=""),E5194,"")
=IF(
AND(
OR( C5194="SHOT10", C5194="SHOT15", C5194="SHOT20", C5194="SH15", C5194="SH20" ),
H5194="",
I5194=""
),
E5194,
""
)