Excel Multiple Lines
In excel i have cells with multiple lines in them - like this
25 Eagle Street
Boondall
What i am trying to do is make them back into one line again as follows -
25 Eagle Street Boondall
Is there some sort of way i can do this in excel? I have over 40000 cells to sort that are multiple lines. I am using a c# i created to separate the suburbs from the addresses, but i cannot do this with these multiple lines because i will get incorrect results. Help would be greatly appreciated.
If these are line breaks entered by pressing Alt+Enter, you can replace them all with Excel's find/replace command. Select "Edit > Replace..." form the main menu or press the shortcut Ctrl+H and in the "Find what:" box you can enter the line-break code, which is character 10. To do this, press and hold the Alt key, and then enter the numbers 010 from the numeric keypad. You'll probably want to replace them with a space to maintain formatting.
Related
for example, the plain text is:
a{tab}{tab}c
note here have 2 tabs between a and c, paste it into excel, normal result is 3 cells: 1=a, 2=empty, 3=c.
but one pc is different, it just get 2 cells: 1=a, 2=c.
excel 2010 x64, please help.
Import text and Text to Columns have very similar interfaces and both 'remember' previous settings.
One of the settings is 'Treat consecutive delimiters as one'. It seems your rogue PC has this setting 'remembered' while the others do not.
I discovered a trick, but Excel doesn't want to cooperate fully... but maybe there's a workaround...?
I often end up with a date/time on a "tall row" (since other columns are multi-line):
...and I'd like to save vertical space by splitting the date/time onto 2 lines, while keeping it a single numeric value for reasons of sorting, etc:
I realized that this can be accomplished by using a ␊LineFeed character in the custom number format, one of two ways:
Method #1: On a keyboard with a numeric keypad:
Select the cell with the value.
Hit Ctrl+1 to open the Number Formats dialog.
Choose the Custom category and then in the Type: textbox:
Enter the first part of your custom format, ie. yyyy-mm-dd
While holding down Alt enter 0010 on the numeric keypad, and then release Alt
Enter the second part of your custom format, ie. HH:mm am/pm
Hit Enter.
Drag between the row headers to make the row twice as tall:
If Wrap Text is not already on, click it on the Home tab of the ribbon:
👉 Alt + 0010 enters a ␊LineFeed character.
Note: Since Excel doesn't expect this character, the first line you enter in the Type box will disappear as soon as you enter the ␊LineFeed character. There's no way to see it within the dialog (without deleting the ␊LineFeed), but it's still there.
Method #2: On a keyboard without a numeric keypad and/or using VBA:
In the VBA Editor, either within your procedure, or in the Immediate Window (Ctrl + G), you can set the number format for A1 with something like:
Range("A1").NumberFormat="yyyy-mm-dd" & vbLf & "HH:mm am/pm"
...then adjust the row height and make sure Wrap Text is on, via VBA or with steps #5 & 6 above.
👉 vbLf (or Chr(10)) represents a ␊LineFeed character in VBA.
My issue:
This is cool, but it seems that Excel still treats the value like it's one long string on a single line.
This is demonstrated by:
double-clicking between column headers to AutoFit the column:
The column does not "shrink" any further.
double-clicking between row headers to AutoFit the rows:
The row does not "grow to double height".
manually dragging the column to a narrower size.
Excel "thinks" the value doesn't fit:
Any ideas for a workaround?
Perhaps there's a hack to force Excel to display partial values instead of ###### when a formatted numeric value doesn't fit?
Thanks!
You have to shrink-wrap it. See the OP's edit here:
Prevent hash signs (#) showing up in Excel without changing cell format or width
Go to the Alignment tab in the Format Cells dialogue.
Select "Shrink to fit".
Select "Wrap text".
Click "OK".
Excel will still auto-size the column to ~139 pixels, but you can drag the column width to ~71 pixels and still see both lines.
Make sure the Shrink to fit function is ticked
Go to: Right click on cell --> Format Cells --> Alignment --> Shrink to fit
For this example, you can split on two cells instead of doing that. On the first cell, just put the date format without time. On the second cell, do a formula =(the first cell), but put it in time format.
I am looking at a way to shrink this to fit on multiple lines in a cell, but it looks like we don't have the technology to do that automatically in 2020.
I have 100's of rows of data, each row containing a list of multiple items separated by comma. for example:
a fox, a frog, a dog, candy,
tyler, daren, hogge, laura,
cat in the hat, remembering your favorite day, having a fun time
etc
as you can see, its not a simple "lastname, firstname" separation.
the issue im having is when i use text to columns, i can easily separate by comma, but im then left with a space before every second item in the list. I need to remove the space after each comma (but not EVERY space after each word!)
I cant just select "comma" and "space" in the delimiters option, because then it removes EVERY space between words (eg 'havingafuntime') when i only want to remove THE ONE space after the comma.
I know i can use "trim" - but im wondering if theres a way to remove the space WHILE SEPARATING THE TEXT TO COLUMNS, all in one swoop.
When working "normal" with excel you can simply left out any formulas for this case.
Instead of the =SUBSTITUTE(A1,", ",",") you can simply select the range you want to be corrected (like the whole A:A column) and press Ctrl+H (replace). Set "Find What" to ", " and "replace with" to "," (without the "). Hit replace all the to do it for the whole selection (non selected cells won't be replaced).
The build-in "Text to columns" can not be manipulated in a way to do it in one step.
EDIT:
Doing it as a one-click-macro just this 4 lines should do what you desire:
Sub text2cols()
Selection.Replace ", ", ","
Selection.TextToColumns Selection.Resize(1, 1), 1, , , , , True
End Sub
Just select the range you want to seperate and run the macro ;)
in the cell adjacent to the start of the column you are going to convert using text to columns, enter the following formula and copy down.
=substitute(A1,", ",",")
This will remove the space after every ,
Then copy and paste as value the resulting column.
Then perform your Text to Columns operation using , as you delimiter.
Another option would be to use Power Query.
Depending on your version of excel you should be able to download an install Power Query by googling "Download Power query for Excel 20X"
click in your data set
On Power query tab you will see "From Table" (in excel 2016 its already in data tab, you do not have to download it)
choose if your data has header or not
Go to Transform
Under Split column choose by delimiter
Choose comma
Under Format you will see Trim
Go to Home tab choose close and load
and you're done
I know this is an old post, but I found this doing a google search because I had the same problem as the OP. However, upon reading some of the suggestions it came to me that I can use the Find & Replace feature. I selected the column in question and did the following:
Find what: ", " (without quotes - used to show space)
Replace with: , (no space)
Essentially this made the list go from: a fox, a frog, a dog, candy, tyler, daren, hogge, laura, cat in the hat, remembering your favorite day, having a fun time
And changed it into this: a fox,a frog,a dog,candy,tyler,daren,hogge,laura,cat in the hat,remembering your favorite day,having a fun time
Then I just used the Text To Column function delimited by comma and it worked beautifully.
I hope this helps someone else out.
I have a list of employee names. Some names are in the format as
John Smith
Some names on the same list are listed as
Jane Smith (Terminated)
For the terminated names I need to remove the (Terminated) in excel.
How do I do this?
A simple solution is to use the replace function:
=SUBSTITUTE(C3,"(Terminated)","")
Where C3 is the cell that contains the text you want to modify.
Since you do not have Formula or VBA tags on your question, another way to do this is to use the Find and Replace functionality of Excel.
1
On the sheet where you wish to remove the parentheses with text, press Control-F on the keyboard.
2
When the dialog opens, click the Replace tab.
3
Type the following WITHOUT the quotation marks:
" (Terminated)"
Notice that there is a space character just before the first paren. Again, don't type the quotation marks.
4
Leave the Replace with field blank.
5
Click the Replace All button.
How do I remove leading or trailing spaces of all cells in an entire column?
The worksheet's conventional Find and Replace (aka Ctrl+H) dialog is not solving the problem.
Quite often the issue is a non-breaking space - CHAR(160) - especially from Web text sources -that CLEAN can't remove, so I would go a step further than this and try a formula like this which replaces any non-breaking spaces with a standard one
=TRIM(CLEAN(SUBSTITUTE(A1,CHAR(160)," ")))
Ron de Bruin has an excellent post on tips for cleaning data here
You can also remove the CHAR(160) directly without a workaround formula by
Edit .... Replace your selected data,
in Find What hold ALT and type 0160 using the numeric keypad
Leave Replace With as blank and select Replace All
If you would like to use a formula, the TRIM function will do exactly what you're looking for:
+----+------------+---------------------+
| | A | B |
+----+------------+---------------------+
| 1 | =TRIM(B1) | value to trim here |
+----+------------+---------------------+
So to do the whole column...
1) Insert a column
2) Insert TRIM function pointed at cell you are trying to correct.
3) Copy formula down the page
4) Copy inserted column
5) Paste as "Values"
Should be good to go from there...
Without using a formula you can do this with 'Text to columns'.
Select the column that has the trailing spaces in the cells.
Click 'Text to columns' from the 'Data' tab, then choose option 'Fixed width'.
Set a break line so the longest text will fit. If your largest cell
has 100 characters you can set the breakline on 200 or whatever you
want.
Finish the operation.
You can now delete the new column Excel has created.
The 'side-effect' is that Excel has removed all trailing spaces in the original column.
If it's the same number of characters at the beginning of the cell each time, you can use the text to columns command and select the fixed width option to chop the cell data into two columns. Then just delete the unwanted stuff in the first column.
I've found that the best (and easiest) way to delete leading, trailing (and excessive) spaces in Excel is to use a third-party plugin. I've been using ASAP Utilities for Excel and it accomplishes the task as well as adds many other much-needed features. This approach doesn't require writing formulas and can remove spaces on any selection spanning multiple columns and/or rows. I also use this to sanitize and remove the uninvited non-breaking space that often finds its way into Excel data when copying-and-pasting from other Microsoft products.
More information regarding ASAP Utilities and trimming can be found here:
http://www.asap-utilities.com/asap-utilities-excel-tools-tip.php?tip=87
I was able to use Find & Replace with the "Find what:" input field set to:
" * "
(space asterisk space with no double-quotes)
and "Replace with:" set to:
""
(nothing)