I have a concat formula returning me a comma separated list of names in a cell
=concat(A2:A10 & " ,") returning [john, jack, jill] in the cell
Is there a way to add to this formula to expand to
john
jack
jill
in a column like that above?
You can change the separator to be a line break =CONCAT(A2:A10 & CHAR(10)) or =TEXTJOIN(CHAR(10),TRUE,P3:P5)
The target cell needs to be set to Wrap Text for the line breaks to be displayed correctly.
I used Power Editor to convert the cell into rows
Related
I have a excel sheet having n number of rows with six columns
I need to insert all these rows into a database table.
So I want to convert each row cells into comma separated and marked by quote list.
Also if any cell is empty then its value should be marked as empty string('')
Example:
Sample image
Try this.
=IF(A1>0,"'"&A1&"', ",""",")&IF(B1>0,"'"&B1&"', ",""",")&IF(C1>0,"'"&C1&"', ",""",")&IF(D1>0,"'"&D1&"', ",""",")&IF(E1>0,"'"&E1&"', ",""",")&IF(F1>0,"'"&F1&"'", """,")
Use TEXTJOIN with "do not skip empty cells" and use quote-comma-quote as the join. Prepend and append a single quote, and you're done:
="'" & TEXTJOIN("','",FALSE,A1:F1) & "'"
Dears,
I want to merge more than one cell and put it inside a new cell. Please see the below image for the example.
Thanks for your support.
Example:
Try:
Range ("b12").value = range ("b2").value & vbLf & range ("b3").value & vbLf etc...
In-Cell Line Break
You can use the in-cell line break, keyboard shortcut ALT+ENTER, and enter the values one below other inside one cell.
So in B12 you type
121
ALT+ENTER
123
ALT+ENTER
...
Formula with line breaks
You can use a formula to achieve the result.
=IF(A2=A1;C1&CHAR(10)&B2;TEXT(B2;"#")), where CHAR(10) is a line break character.
Then you select the cells with result and toggle word wrap on. See picture:
You can then copy and paste as values, delete the rows you dont need.
I have a cell with the contents of 41316. I have it formatted as 20130211.
I need another cell to reference that value, but in the cell have it showing as 20130211 not 41316 formatted.
This maybe an easy one, but for some reason it has me running in circles.
Thanks in advance for all responses.
Excel by default copies the format from a cell formatted as a date to a cell which references it. It sounds in your case that Excel hasn't done that for you, so you just need to format the new cell with your special format : paintbrush tool or Edit..Copy, Edit..Past Special..Formats or Format..Number..Custom and select your format, which will be at the bottom of a long list.
If a string is ok instead of a number, you can decompose that date in parts and concatenate:
Being A1 the cell containing the value:
= Year(A1) & "/" & Month(A1) & "/" & Day(A1)
The "&" symbol concatenates text. The slashes are optional if you want them separated by slashes.
if your cell referencing 20130211 is 'A1' put =TEXT(A1,"####") in your calculation cell. If you do it this way then it will still read as a number and not a string
I have a column with some text in each cell.
I want to add some text, for example "X", at the start of all cells. For example:
A B
----- >>>> ----
1 X1
2 X2
3 X3
What is the easiest way to do this?
Type this in cell B1, and copy down...
="X"&A1
This would also work:
=CONCATENATE("X",A1)
And here's one of many ways to do this in VBA (Disclaimer: I don't code in VBA very often!):
Sub AddX()
Dim i As Long
With ActiveSheet
For i = 1 To .Range("A65536").End(xlUp).Row Step 1
.Cells(i, 2).Value = "X" & Trim(Str(.Cells(i, 1).Value))
Next i
End With
End Sub
Select the cell you want to be like this,
Go To Cell Properties (or CTRL 1)
under Number tab
in custom
enter
"X"#
Select the cell you want to be like this, go to cell properties (or CTRL 1) under Number tab in custom enter "X"#
Put a space between " and # if needed
Select the cell you want,
Go To Format Cells (or CTRL+1),
Select the "custom" Tab, enter your required format like : "X"#
use a space if needed.
for example, I needed to insert the word "Hours" beside my numbers and used this format : # "hours"
Enter the function of = CONCATENATE("X",A1) in one cell other than A say D
Click the Cell D1, and drag the fill handle across the range that you want to fill.All the cells should have been added the specific prefix text.
You can see the changes made to the repective cells.
Option 1:
select the cell(s), under formatting/number/custom formatting, type in
"BOB" General
now you have a prefix "BOB" next to numbers, dates, booleans, but not next to TEXTs
Option2:
As before, but use the following format
_ "BOB" #_
now you have a prefix BOB, this works even if the cell contained text
Cheers, Sudhi
Michael.. if its just for formatting then you can format the cell to append any value.
Just right click and select Format Cell on the context menu, select custom and then specify type as you wish... for above example it would be X0. Here 'X' is the prefix and 0 is the numeric after.
Hope this helps..
Cheers...
Go to Format Cells - Custom. Type the required format into the list first. To prefix "0" before the text characters in an Excel column, use the Format 0####. Remember, use the character "#" equal to the maximum number of digits in a cell of that column. For e.g., if there are 4 cells in a column with the entries - 123, 333, 5665, 7 - use the formula 0####. Reason - A single # refers to reference of just one digit.
Another way to do this:
Put your prefix in one column say column A in excel
Put the values to which you want to add prefix in another column say column B in excel
In Column C, use this formula;
"C1=A1&B1"
Copy all the values in column C and paste it again in the same selection but as values only.
Type a value in one cell (EX:B4 CELL). For temporary use this formula in other cell (once done delete it). =CONCAT(XY,B4) . click and drag till the value you need. Copy the whole column and right click paste only values (second option).
I tried and it's working as expected.
original column is like:
0.45::rafas::4.0::0.0::0.9
0.35::rasaf::4.0::110.0::1.0
and i would like to break the string in to the following (:: as separator) in Excel
col1 col2 col3 col4 col5
0.45::rafas::4.0::0.0::0.9 0.45 rafas 4.0 0.0 0.9
0.35::rasaf::4.0::110.0::1.0 0.35 rasaf 4.0 110 1.0
Please help.
This page explains how to do just that using the "Text to Columns" function.
Copied for your convenience:
Highlight all of your cells with the data.
Select The Topmost Cell In The Column, E.G. A1 Hold CTRL+SHIFT And
Then Press The Down Arrow. OK, Once We've Done That, Go To "Data" Menu
And Select "Text To Columns". On The Text To Columns Window, Select
"Delimited" And Then Hit "Next". In The Following Window, Choose
"Other" For Type Of Delimiter And Use The Minus/Hyphen Sign - Hit
Finish.
Now you will have two columns, from your example, the first column
will contain data like "Animals" and the other column will contain the
data " House of The Rising Sun". (note the SPACE in front of "House")
To get rid of that SPACE we're going to use the TRIM function.
In cell C1 (or the column to the right of the song titles) type in
this formula.
=TRIM(B1)
Then double-click on that little black box on the excel cursor to copy
the formula down the whole range. Any spaces at the Start or end of
the text string will be removed.
If you wanted to do it with forumlae rather than the "text to columns" functions you could use:
Assuming string in A1
in B1: =FIND("::",$A1)
in C1: =FIND("::",$A1,B1+1)
Then copy C1 over D1:E1
in F1: =MID($A1,1,B1-1)
in G1: =MID($A1,B1+2,C1-B1-2)
Then copy G1 over H1:I1
And finally
in J1: =MID($A1,E1+2,LEN($A1)-E1-1)
The results of the split will be in F1:J1. You can always hide columns B:E as they are just internal to the splitting. This can then be done on as many rows as you need and if the value in A1 is update all other values will be changed. However, it is on a fixed number of columns but can easily be expanded if needed.
Excel (and OpenOffice) have a functionality to split Text into Columns. Highlight all the columns that conform to this schema, then go to the Data menu, and select "Text to Columns". Used a delimited separator and specify it as ":" while treating consecutive delimitors as one.
Here is a very simple way to extract the 5th character from the left from a text string in Excel:
Suppose the character string ABCDEFGHIJ is stored in cell A1 in an Excel Spreadsheet, then the following formula
=RIGHT(LEFT(A1,5),1)
produces the 5th character from the left in the string, namely āEā.
If you would like a simple function, you can use the following VBA code.
Function SplitTextToNum(rngInput As Range, sepString As String)
Dim CallerRows As Long, CallerCols As Long, DimLimit As Long
Dim outvar As Variant
outvar = Split(rngInput.Value, sepString, -1, vbBinaryCompare)
If Application.Caller.Rows.Count > 1 Then
SplitTextToNum = Application.Transpose(outvar)
Else
SplitTextToNum = outvar
End If
End Function
You can use Ctrl+Shift+Enter over a range of cells after entering the formula referring to the cell in which you have the string that you need to be split up.