Posts tagged function
Removing line breaks within a cell
Nov 18th
Did you know that you can put line breaks inside excel cells? It’s quite straight forward, within the cell just click ALT + Enter to make the line break. An example is if an address is entered in a single cell:
Personally it’s not something that I would use often as it makes the data harder to extract and analyse, but what happens if you have a spreadsheet has these incell line breaks, and need to break them out into columns? In the example here you may want to do an analysis on the geograhic spread or want to do a mail merge so want a list with columns for towns, counties etc.
If the lines were in separate cells you could use the paste special > transpose option to convert vertically listed data items into horizontal and vice versa however in this instance it won’t work as all the data is in a single cell. Instead what we need to do is remove the line breaks.
Using ALT + ENTER means that Excel inserts a line feed character, or ASCII CHAR(10) which shows as a new line. We need to remove these instances of CHAR(10) which appear invisible on screen and replace them with something else to act as a delimiter which we can then use to break the data into columns.
- To start with add a new helper column on your spreadsheet, in this instance it would be column B and type the formula =SUBSTITUTE(A1,CHAR(10),”£”)
- Fill this formula down against the rows that you have. This formula searches the cell indicated (eg cell A1) for all instances of CHAR(10) and substitutes them with £
- You can then use the Text to Columns function to break the data into columns using £ as the delimiter. You can of course use any character you like rather than the £ however make sure that it’s something you know doesn’t already appear in your data as otherwise the columns may break in the wrong places. And watch out for using the wildcard characters too (see my previous post on searching for wildcard characters)
The other alternative is to use find and replace to identify the line feed breaks which may be more appropriate if you have a large dataset with line breaks within the cells that need removing in a number of different columns. across the spreadsheet. However if you open the find and replace dialog box (CTRL + H) and type ALT + ENTER in the find box what happens? Erm, yes nothing – it just moves to the next box. Instead in the find box hold down ALT and type 010 then move the replace box and type in what you want the delimiter to be – eg £. Click Replace all and it should do the same as above but without the helper column.
The power of Save As and your Excel spreadsheet
Sep 27th
I often tell people that F12 is one of the most useful keyboard shortcuts for any of the Microsoft products, including Excel, and certainly it is one of the ones that has been most useful to me. But why is Save As so important?
It’s simply a way of saving your spreadsheet or document in another way. This could either be with another name, or possibly into a different format (either a previous version of the software, or perhaps in an entirely different form such as pdf or .txt)
For me it’s using it to save a spreadsheet as another name which has been so useful, this gives the opportunity to have an “Original” version of a spreadsheet to return to whilst you try out some new functions and take your analysis in different ways with no fear of harming your source data. You can always return to the first version if needed.
Just a word of cation though, firstly make sure your new file names are meaningful and secondly that you don’t get click happy using F12 too often, ending up with multiple copies with helpful titles as “ORIGINAL Version 1 FINAL” or “Wednesday version 3 FINAL original use this one”.
Do you Save As and find it useful? What’s your favourite shortcut? Do leave me a comment below