I have a column having values as
A
1.decode(D01,1,1,3,3,4)
2.decode (d02,1,1,3,3,4)
3.decode(d03,1,1,3,3,4)
...
...
31.decode(d31,1,1,3,3,4)
and i need to have these columns in a string seperated by comma as
decode(D01,1,1,3,3,4), decode (d02,1,1,3,3,4), decode(d03,1,1,3,3,4)
and so forth up to 31 such values in a comma separated list.
How will I be able to do this in excel?
You can do a CONCATENATE over all the rows like:
=CONCATENATE(A1&", "&A2&", "&A3&", "&A4&", "&A5&", "&A6&", "&A7&", "&A8&", "&A9&", "&A10&", "&A11&", "&A12&", "&A13&", "&A14&", "&A15&", "&A16&", "&A17&", "&A18&", "&A19&", "&A20&", "&A21&", "&A22&", "&A23&", "&A24&", "&A25&", "&A26&", "&A27&", "&A28&", "&A29&", "&A30&", "&A31)
Or You can create and use something like the ConcatenateRange presented in this answer
Or You can do:
Set cell B1 to "=A1"
Set cell B2 to "=B1&", "&A2"
Copy cell B2 all the way down to B31
Cell B31 will now contain the concatenated text string you are looking for.
Related
I have an Excel spreadsheet with 7 cells (in a column) with data in, these are C13 to C19
I have a formula that combines all the data in these cells together and puts it into one cell, this formula is =C13&", "&C14&", "&C15&", "&C16&", "&C17&", "&C18&", "&C19 and works fine. However, can I alter this formula to miss out on any cell that contains the text "Nothing else carby"?
You may, in Excel 2019, use:
=TEXTJOIN(", ",,IF(C13:C19<>"Nothing else carby",C13:C19,""))
If "Nothing else carby" can be a substring inside a cell's value, try:
=TEXTJOIN(", ",,IF(ISNUMBER(FIND("Nothing else carby",C13:C19)),"",C13:C19))
Confirm through CtrlShiftEnter
The formula should not be that long, as you can see:
=TEXTJOIN(",",TRUE,IF(C13:C19="Nothing","", C13:C19))
(I just used "Nothing" instead of the whole word for readability reasons.)
Explanation of the parameters:
"," : delimiter: between every cell content, a comma is added.
TRUE : treatment of blank cells (don't put them).
IF (...) : In case cell content is "Nothing", put an empty string.
In combination with the previous parameter,
just one comma will be put in the result:
"a,b,c,e,f,g" and not "a,b,c,,e,f,g" (see result).
Used data:
a
b
c
Nothing
e
f
g
Result:
a,b,c,e,f,g
In a cell I have a multi value separated by semicolon like this:
Red;Blue;Green
I need to compare if each of those values exist on a list:
Black
Orange
Green
Blue
Red
I think it should be an array formula, but I have no idea how to set it.
Is it even possible?
Regards
Michał
You've not mentioned what output you are looking for. Below are the two possible solution.
1. If you are looking for the count of words in a cell from the list use following formula:
=SUMPRODUCT(ISNUMBER(FIND($E$2:$E$6,$A2))*1)
2. If you want words in the cell that are in the list to be displayed in separate columns, use the following array formula
=IFERROR(INDEX($J$2:$J$6,SMALL(IF(ISNUMBER(FIND($J$2:$J$6,$A2)),ROW($J$2:$J$6)-ROW($J$1)),COLUMNS($A1:A1))),"")
Drag/copy above formula across and down as required.
Being an array formula you'll have to commit this formula by pressing Ctrl+Shift+Enter.
You can write this UDF and use it as a formula. Wasn't sure what output is required. This UDF gives number of items that match in the list.
Parameters:
myValue - the cell that contains multi value separated by semicolon
listRange - Range that has the list to check against. Should be a single column list
Function checkList(myValue As Range, listRange As Range) As Integer
Dim t As Variant
t = Split(myValue.Value, ";")
Dim c As Integer
c = 0
For i = LBound(t) To UBound(t)
For j = 1 To listRange.Rows.Count
If (t(i) = listRange(j, 1)) Then
c = c + 1
End If
Next j
Next i
checkList = c
End Function
Since you want to do this only with excel formulas, the input string has to be split to multiple cells before comparing it with the list.
If your input string is in A1, use the below formula and drag it right to split them based on the delimiter ;.
=TRIM(MID(SUBSTITUTE($A1,";",REPT(" ",999)),1+((COLUMN(A1)-1)*999),999))
Assuming your list is in column G, use the below formula which counts the strings Red, Blue and Green in your list and returns Found or Not found.
in C2,
=IF(COUNTIF($G:$G,C1),"Found","Not found")
Hope this helps.
Using MS Excel 2010: I used the CONCATENATE formula to create a text string that looks like a formula and need a formula that will convert the text string to a formula; without the use of MS Excel Paste Special function or VBA/Macro.
Example: In Cell B2:G2 contains text, in Cell B4 I have CONCATENATE text formula that returns a text string
=TRIM(CONCATENATE(B2&" "&C2&" "&D2&" "&E2&" "&F2&" "&G2&" "&H2))
I want Excel to interpret this string as a formula and return/show the value in Cell B6 as: "Always be yourself … do not go out and look for a successful personality and duplicate it.” - Bruce Lee
I have attempted using the INDIRECT formula and without success, not certain if it's my formula or if it's possible. SAMPLE: Cell B6:
=INDIRECT(CONCATENATE("B4"))
1) CONCATENATE and & are the same thing. In other words the formula you wrote as a string could be translated as:
=TRIM(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(B2)," "),C2)," "),D2)," "),E2)," "),F2)," "),G2)," "),H2))
If you are going to write out CONCATENATE for you function, then separate all he strings you want joined together as with a coma as has been pointed out by #MarcoVos in the comments to your question:
=CONCATENATE(B2," ",C2," ",D2," ",E2," ",F2," ",G2," ",H2)
Or if you want to use the more common form of & your formula would look like what you originally posted without the CONCATENATE out from like this:
=B2&" "&C2&" "&D2&" "&E2&" "&F2&" "&G2&" "&H2
Those last two formulas will produce the same results.
2) The INDIRECT function will convert text to a cell references or address. It will not convert a formula as text and spit out the results of the formula. Macros Vos in his answer is correct in that FORMULATEXT() will display the formula in the referenced cell as text or a string. If you need to follow a sequence where you provide the string and then must convert the string into a formula, then I suggest you use the EVALUATE Function. You cannot use EVALUATE from a regular excel formula though. You can call it from a named range though. Create a named range. Lets for example call it EvalText. In the formula portion for creating the named range, enter:
=EVALUATE($B$4)
It will automatically add the sheet name. Now in any cell on your sheet you can enter:
=EvalText
and it will return whatever the string in B4 works out to be as a formula. It will spit out an error if its not a proper excel formula.
Why not do it the other way around?
Put:
=TRIM(CONCATENATE(B2&" "&C2&" "&D2&" "&E2&" "&F2&" "&G2&" "&H2))
in cell B6 and
=FORMULATEXT(B6)
in cell B4.
The problem with the named "Range" is that it is not part of the Recalc-Loop.
Defining (in VBA) a function
Function MyEval(text As String)
MyEval = Evaluate(text)
End Function
and adding
Private Sub Worksheet_Change(ByVal Target As Range)
Application.CalculateFull
End Sub
to the codesheet of the worksheet under consideration
solves the problem.
Of course, the workbook than has t be saved as XLSM.
I have a range of cells. I want to format any of the cells in the range that contain a certain text string.
The problem is, the text string is constructed in 2 parts. The first part is a reference to another cell which can contain different text strings (the cell is actually referencing another cell, which is a drop down list with several choices). The second part is an actual defined text string.
In my example, cell G2 contains the string "REFERENCED CELL &".
In the range B2:B11, my formula is:
=IF(AND($E$2>=1,$E$2<=10),$G$2&" TEXT STRING 1",IF(AND($E$2>=11,$E$2<=20),$G$2&" TEXT STRING 2",""))
So:
If cell E2 contains a value that is between 1 and 10, then the cells in the range will contain the text string in cell G2 followed by the text string " TEXT STRING 1".
If cell E2 contains a value that is between 11 and 20, then the cells in the range will contain the text string in cell G2 followed by the text string " TEXT STRING 2".
I want to format this range differently for each of these outcomes.
If the resulting string is "REFERENCED CELL & TEXT STRING 1" then the cell will be red.
If the resulting string is "REFERENCED CELL & TEXT STRING 2" then the cell will be green.
How can I perform conditional formatting on a cell when its value is created in this way?
An alternative approach:
where the two rules are (assuming integers):
Green =AND(E$2>10,E$2<21)
Red =AND(E$2>0,E$2<11)
This solved the issue: =$B$2=$G$2&" TEXT STRING 1" and =$B$2=$G$2&" TEXT STRING 2"
I have a comma delimited string (aad,adaa,,dadae,,,eresa,,baaa) in cell A1 of Sheet1 which I want to split and insert values in a column such as:
aad
adaa
dadae
eresa
baaa
Empty values will skip a cell and insert the string in next cell.
I am able to separate the string to a row but how could I do it to a column?
Here is my line to split the string to a row:
Sheets("Sheet1").Range("A1").TextToColumns
Call WorksheetFunction.Transpose() after splitting to columns.
No need to use TextToColumns either, Split will suffice:
Range("A1:A9").value = WorksheetFunction.Transpose(Split("aad,adaa,,dadae,,,eresa,,baaa", ","))