I was wondering if there is a way to make a formula than uses a cell n times, for example:
=concatenate(A1,", ","some string")
=concatenate(A1,", ","some string")
=concatenate(A2,", ","some string")
=concatenate(A2,", ","some string")
and so on.
Here what I want to show is that cell A1 is repeated 2 times, then A2 two times as well, etc.
How can I achieve that with just drag the cells down.
And also I need to achieve this:
A B C
one dog one dog
two cat one cat
three two dog
four two cat
three dog
three cat
in this case, I want to concatenate the values from column B, thats why I need to repeat it two times
You can use an Index function to identify which cell to concatenate. For a regular pattern of using every row twice, use
=CONCATENATE(INDEX(A:A,ROUNDUP(ROW()/2,0)),", ","some string")
Copy down.
Please try:
=INDIRECT("A"&(MOD(ROW(),2)+ROW())/2)&", some string"
A version for repetition three times:
=INDIRECT("A"&FLOOR(1+(ROW()-1)/3,1))&", some string"
or for repetition two times with alternating strings from B1:B2 :
=INDIRECT("A"&(MOD(ROW(),2)+ROW())/2)&" "&IF(ISODD(ROW()),B$1,B$2)
Once the formulae have achieved the appropriate expansion they should be selected, Copy, Paste Special, Values over the top to replace the formulae with the results of the formulae.
Not that I know of without using VBA, but you could change the formula (assuming those formulas start in cell b1) to:
=concatenate(indirect(A1),", ","some string")
and then in cell A1 you'd type in whatever cell you wanted to reference, so in cell A1 you'd type in a1 and then in cell A2 you'd type in a1 again.
Related
Is there any way to use cells of excel in my mathematical equations? I'd like a way to just change the numbers and the equations automaticlly update with them. I tried concatenating strings but it's not that pretty. Or maybe is there any other way to easily show equations step by step in excel?
You say that concatenation of strings is not that pretty, so I assume you have done something like:
in cell A1 : "Hello"
in cell A2 : "World"
in cell A3 : =A1&A2
And in cell A3, you see "HelloWorld", without any space (which is indeed not pretty).
You can solve this in two ways in A3:
=A1&" "&A2
=TEXTJOIN(A1:A2, " ")
(I'm not entirely sure about the syntax of the second one.)
In the first formula, you concatenate both cells A1 and A2 and you specifically mention to put a space between those two.
In the second you do the same, but you mention that the space must be used everywhere.
The difference can be seen in following example:
In cell A1: "Hello"
In cell A2: "Lovely"
In cell A3: "World"
In cell A4, you can put: =A1&" "&A2&" "&A" for getting "Hello Lovely World": you need to mention the space character twice.
In cell A4, you can put: =TEXTJOIN(A1:A3, " ") for getting the same result. As you see you only need to mention the space character once.
Is this what you are looking for?
Lets say we have two cells A1 and A2:
A1: A, B, 13
A2: C,B,14
Which are Strings. I want to add the values at the end of each cell-string.
Hence what I do to extract a value of a specific cell:
=VALUE(RIGHT(A1, SEARCH(",",A1))))
Returns 13 as a VALUE (or int).
Now, is there a way to add A1 and A2 in a SUM function? I could not find a way to loop through each A cell in a SUM range and work the VALUE magic on it.
A very bothersome solution would be to add all the values together like so:
=SUM(VALUE(RIGHT(A1, SEARCH(",",A1))),VALUE(RIGHT(A2, SEARCH(",",A2))))
But that does not seem optimal. I tried around with IF but it seems that what I am missing is simply the While/For loop to iterate through a range.
With data in A1 through A10, pick a cell and enter:
=SUMPRODUCT(--(TRIM(MID(SUBSTITUTE(A1:A10,",",CHAR(1),2),FIND(CHAR(1),SUBSTITUTE(A1:A10,",",CHAR(1),2))+1,9999))))
The formula isolates the string after the second comma; converts it into an integer; and then sums the integers.
(just be sure that your SUMPRODUCT() covers only cells with data and not any blank cells)
EDIT#1:
a somewhat shorter formula is:
=SUMPRODUCT(--TRIM(RIGHT(SUBSTITUTE(A1:A10,",",REPT(" ",LEN(A1:A10))),LEN(A1:A10))))
EDIT#2:
The "shorter" formula works by replacing all commas with a great number of spaces, so many spaces in fact, that when we look at the RIGHT() part of the expanded string, all we see are spaces followed by some numbers. TRIM() removes these spaces, leaving us the numbers.
I am trying to insert a value in a column into 3 other columns in the same row.
Basically inserting A1 into a string in columns B1, G1 and F1.
row1 would have:
A1= LSL3007, B1= [SyrupRoom]LSL0201.Fault.sts_tripped, G1= [SyrupRoom]LSL0201
and I would like to replace the LSL0201 with LSL3007.
row2 would have
A2= LSL3007, B2= [SyrupRoom]LSL0201.Fault.sts_tripped, G2= [SyrupRoom]LSL0201
and I would like to replace the LSL0201 with LSL3008.
This goes on for about 500 rows.
Like I mentioned in my comment you can use the Substitute function.
Substitute has 3 parameters, the original string, the string you want to change, and the string you want to replace it with. It is basically find and replace.
Since you have 3 columns you will have to do this 3 times.
As a case example say A1 = LSL3007, and B1 = [SyrupRoom]LSL0201.Fault.sts_tripped.
When you click on B1, [SyrupRoom]LSL0201.Fault.sts_tripped, will show up in the textbox (function box) at the top of the page.
Replace this with:
=SUBSTITUTE("[SyrupRoom]LSL0201.Fault.sts_tripped", "LSL0201", A1)
Remember to be careful with quotation marks! It should then fix the string in B1 as you want it.
To apply this to the entire column, you can click on B1, then drag the little box on the bottom right of the cell, or double click on it to apply this formula to the entire column.
Assuming all of the values in the columns are identical as you stated in your question, this should work.
Repeat this for each column, replacing the first string with the unique string for that column.
One last thing, since column F has quotes within the string, you will have to escape them by using double quotes, so it will look like this:
=SUBSTITUTE("Display ""PPT Digital Input"" /T [SyrupRoom]LSL0201", "LSL0201",A1)
I am trying to create a decoding macro. I have different combinations of letters in each cell on one sheet. For example, in cell B2 I would have something like "ABC." On a different sheet I have a table that matches letters to numbers, so I want the output in the new cell to be "123" in that case. I know how to use VLOOKUP on an entire cell, but cannot figure out how to use it on individual parts and then concatenate the results back together in the new cell.
This is what I've figured out so far. I think I need INDIRECT as part of it so I can reference the cell, but I cannot figure out how to look up the different portions of the cell. I do not want to create new columns to split the letter combinations up if possible.
=IFERROR(VLOOKUP("not sure??",'Conversion Table'!A4:B19,2,FALSE),"")
Thanks!
I'm assuming your cell B2 is limited to 3 chars only, and it's the same everywhere. In this case, you can do:
=CONCATENATE(VLOOKUP(MID(B2,1,1),'Conversion Table'!$A$4:$B$19,2,0),VLOOKUP(MID(B2,2,1),'Conversion Table'!$A$4:$B$19,2,0),VLOOKUP(MID(B2,3,1),'Conversion Table'!$A$4:$B$19,2,0))
If you have more chars, only add them using concatenate and select them one by one using MID.
Edit - locked the lookup table.
I think what you may be looking for is this:
A B C D
1 =""
2 ABC =IFERROR(VLOOKUP( =D1&C2
B2,
'Conversion Table'!$A$4:$B$19,
2,FALSE),"")
3 XYZ =IFERROR(VLOOKUP( =D2&C3
B3,
'Conversion Table'!$A$4:$B$19,
2,FALSE),"")
4 PQR =IFERROR(VLOOKUP( =D3&C4
B4,
'Conversion Table'!$A$4:$B$19,
2,FALSE),"")
5 DEF =IFERROR(VLOOKUP( =D4&C5
B5,
'Conversion Table'!$A$4:$B$19,
2,FALSE),"")
The "Final Answer" appears in cell D5
How can I extract the first word of a number of different cells and have each of the first words show together in one other cell separated by comma?
e.g. A1 shows "Firstname1 Lastname1", A2 shows "Firstname2 Lastname2", A3 shows "Firstname3 Lastname3",
I need a formula allowing me to show the following in cell D2 "Firstname1, Firstname2, Firstname3"
I found this solution, which gives me the first word of one cell and shows it in another cell but I don't know how to get the first word of a number of cells and show them all coma separated in another cell
=LEFT(A1,SEARCH(" ",A1)-1)
Excel function to get first word from sentence in other cell
Thanks!
What if instead of just three cells you have an Excel range A1:A100 which has all the names? How would you concatenate in such an instance? Will you type that long a formula?
As Jerry suggested, VBA is Apt for this. But what if you do not want to use VBA or long formulas?
See this example. I am taking 10 cells for the sake of explaining.
Let's say the data looks like this.
Now select the entire column and click on Data~~>Text To Columns
When you click finish, the output will be like this
Now in cell say E4, type this =Transpose(A1:A10). Replace A1:A10 with the actual range. However do not press the Enter key. Press the key F9. You will see that all the first names are now visible.
Simply copy that and press Esc. Now open Notepad and paste it there.
Next delete the { and the }
Next manually replace "," by , and you will get what you wanted.
=LEFT(A1,SEARCH(" ",A1)-1) &", "&LEFT(A2,SEARCH(" ",A2)-1)&", "&LEFT(A3,SEARCH(" ",A3)-1)
using your current formula, =LEFT(A1,SEARCH(" ",A1)-1), you can add the value of subsequent cells to the previous calculation, and build the comma separated values.
in B1, we have your original formula, =LEFT(A1,SEARCH(" ",A1)-1)
in B2 we concatenate the previous result, and add on the comma and the new word:
=B1 & "," & LEFT(A2,SEARCH(" ",A2)-1)
copy this to B3 (and on) and you will slowly see the full list getting created.
The last value is the one you want, so, in C1, put the formula
=OFFSET(B1,COUNTA(B:B)-1,0)
(and hide column B so it looks better)