Thursday, 3 February 2011

Using Symbols in Text

There are times when you want to include a symbol as part of your work. Perhaps in a document where you want the symbol to be the same size as your text.

A good example would be when including contact details. Instead of typing the word Tel: followed by a telephone number, you might want to have a symbol of a telephone number.



You could just find an image of a telephone and use that of course, but then it would be fiddly getting it to the right size and having text flow around it properly.

Luckily for us there are special fonts that we can use. Even every day fonts that you use all the time have some symbols - letters with accents such as "é" for instance. But also other useful ones like the copyright symbol "©", fractions such as ½ and ¾ etc.

Scientific and mathematical symbols are there in most fonts too so you can give the temperature as 31° without having to spell out degrees and use ± instead of writing plus or minus. All my examples so far are there in the standard Arial font.

So too are arrows, letters of foreign alphabets, the four suits of a deck of cards, smiley faces, musical notes... You thought perhaps there would be around 70 or 80 characters in the Arial font? 26 letters, 26 capital letters and a set of numbers plus all the other charaters you see on your keyboard? There are over 150 characters in Arial. But not a telephone... Drat... But all is not lost yet or else how would I have included the telephone symbol at the foot of my email above?

So let's have a look ...er... where to look...

We start by clicking the Start button. Then choose All Programs, Accessories and System Tools. There you will see an icon labeled Character Map.

This does not contain Bill Gates' family tree or employees but something far more useful (unless you are a future descendant looking for the vital link to claim a share of inheritance).

This is what the Character Map looks like. You scroll down to find the symbol you want. You then click it upon which it becomes bigger so you can see if it is the one you thought it was and if it is the one you want to use you click the Select button to add it to the box at the bottom and then the copy button which puts it into the clipboard so that you can now switch back to your document and paste it in the usual way.

If you don't find the sybol you wanted then try a different font.

You can drop down and choose from a list of fonts. Some of these will contain purely symbols. For instance the Webdings and Wingdings fonts. Strangely, the Symbols font is a grave disappointment to most searchers of symbols... Oh, and the Euro symbol "€" has a font all of its own - the Euro Sign font!

When pasted these may revert to other characters from whatever standard font you are using. (I am currently agog with excitement wondering whether all my work in finding the symbols mentioned will actually show up when I post this blog entry!)

If you find your symbols have turned back into somewhat random but ordinary letters in the same manner as Cinderella's coach at midnight then you will have to go back and amend the font. So I'm fairly confident my Arial symbols will show ok but the Euro sign may well just be a "B" or something! (Actually it worked just as it should do!)

I found my telephone symbol in the Wingdings font and it is shown here after I clicked on it, which is why it has expanded to this size.

Enjoy those symbols!

Wednesday, 1 September 2010

Error Trapping in Excel

I had a query about how to set up a spreadsheet for future rows to be added but without showing all the error messages you get when a formula expects there to be something in a cell which hasn't yet had data entered.

Here's an example spreadsheet that works out how many miles per gallon of fuel you are using. I'm old enough to not want to know how many miles per litre I am getting so the spreadsheet converts the litres I buy into gallons.

I have entered data up to row 8 but from row 9 downwards there are either errors or data showing where I don't want to see anything until data is entered into those rows.

The only data I need to enter will go in column A (the date I buy fuel), column B (the mileage shown on the odometer of my car when I refuel) and column D (the number of litres I put in the tank).

A formula in cell C9 =B9-B8 calculates how many miles since the last refuelling. Because there is no data in cell B9 it has calculated a value of -4328 ie zero minus the value in cell B8.

The display in cell E9 is even worse because there is an error message displayed due to the lack of data in cell D9 which is causing a Divide by Zero error.

The formula in cell D9 is =C9/(D9/4.546). The bit inside the brackets (D9/4.546) converts the number of litres into gallons. Then the number of miles travelled, held in cell C9, is divided by the number of gallons to give the miles per gallon figure.

There really is no error here in human terms because the data simply hasn't been entered yet. But unless we want to copy the formulae down every time we add a row of data, the spreadsheet will see a logical error and report it.

So we can use a simple =IF formula to test for the existence of a value in the critical cells before displaying anything.

In cell C9 we have the formula =IF(B9="","",B9-B8).

Let's break down the =IF syntax first then look at what it is doing.

It uses the commas to separate the different segments and takes the form =IF(you find this, then do this, otherwise do this)

If a cell contains nothing, that can be represented by placing the contents (nothing) between a set of double quote marks - "". Note that there is a big difference between nothing and a zero! So we can't use =IF(B9=0...

So the formula is saying; =IF(B9 holds nothing, do nothing, otherwise display B9-B8)

Likewise we can add a similar =IF to the formula in cell E9, in which case the existence of a value in cell D9 are the key to whether we want a value displayed or not.

=IF(D9="","",C9/(D9/4.546))

The formulae can be copied down both columns B and E and each time you refuel you just need to add data to columns A, B and D to complete the row.

Monday, 21 December 2009

Sound and Video Downloads instead of Playing from a Web Page

I recently had a problem with Windows Media Player not opening from a web page. Instead it asked if I wanted to save or download the media file. I have a lot of web pages with sound files attached and this was causing no end of problems so I set about looking for a solution.

A search on Google found that as a Windows Vista user I was not alone in experiencing this and yet, whilst there were lots of suggestions about the cause and solutions, it was obvious that the solutions weren't working for most people. And the suggestions were mainly of the reinstall Windows Media Player variety. Not something I like to do unless it's a last resort and in any case I've found in the past that whatever settings you have, have a tendency to be remembered...

The causes were varied but most forum entries seemed to be blaming the Quicktime software. I had installed that just about the time my problems started - but I had also had to install i-tunes also so there was potentially another cause there.

Anyway in the end I ignored most of the advice and tried this and it worked for me.

Go to the Windows Start Menu and choose Default Programs

Choose Set your default programs. (Most of the suggested solutions instead chose the option to Associate a file type or protocol with a program - so if this doesn't work for you then try this next!)

It may take this next window a few seconds to fully load so remember to breathe and give it a little time!

Select Windows Media Player in the list on the left and Set this program as default in the right even if it says it already has all its defaults.

That worked for me. Going back into a web page and clicking a link to a sound file caused Windows Media Player to open and play the sound file.

Saturday, 25 July 2009

Mouse Pointer Won't Move - Clean the Mouse!

If you have a mouse that has a ball underneath rather than a red light then you are going to have to clean it every now and then.

A lot of computer users get confused when the mouse pointer starts to stick, move in jerks, or fails to move at all despite them running the mouse around the desk like a maniac.

What has happened is that the rollers that the ball presses on to convert the movement into electrical signals have got covered in grease and dust and the ball is slipping on them instead of rotating them.

Turn the mouse over and you will see a plate covering the ball which can be unscrewed by applying pressure with a finger to each side and turning anti-clockwise about a quarter turn.

Turn the mouse back over and the plate and the rubber ball should drop into your hand.

Inside the ball cavity are two long rollers that will be covered in a certain amount of gunge and grot! Look at the spot in between the two rollers and opposite that spot will be a small spring-loaded roller that keeps the ball pressed to the two larger rollers.

Now it's a matter of scraping off the covering of grease and dust, rotating the rollers a little at a time until they are clean all the way round. You could be slightly amazed at the amount of greasy fluff you have to remove! It is caused by the mouse rolling over areas where you have previously rested your hand and the skin's natural moisture mixes with dust to form this material. Clean the small spring-loaded roller too - this is a bit more difficult because the pressure of your finger makes it retreat into the body of the mouse against its spring!

Once you have cleaned the rollers, use a small paint brush to clean the ball cavity.

The ball itself probably won't need cleaning but in extreme cases it can be cleaned by brushing it with a slightly stiffer brush. Don't be tempted to wash or wet it. Clean Blue Tack can be useful to pick off bits, but make sure you don't leave any shreds of Blue Tack on the ball.

Before putting the ball back, clean off any debris and grease from the underside of the mouse casing - the feet and around the edges of the label.

Lastly drop the ball back in, taking care not to handle it unnecessarily - you'll just transfer more grease onto it - and then place the retaining plate back over it, aligning the lugs and twisting clockwise to secure it. Your mouse should now work perfectly for another couple of weeks or so!

Wednesday, 22 July 2009

Excel: Manipulating text with LEFT, RIGHT, LEN, FIND, IFERROR

This entry solves the problem of having a single field for someone's name in a spreadsheet but then wanting to split it into forename and surname - perhaps because you want to sort rows alphabetically by name - hmm... yes... there's another entry to come!

This one was suggested by a colleague, Patrick Bellis and he did actually provide a solution as well. I've had a fiddle and come up with an enhanced version though that shows how to deal with entries that have two forenames or a middle name or initial. It doesn't deal with more than one middle name or initial although you can do that easily - details later!

So in my simple example, the Full Name field was the previously existing field and I have used formulae to split this into the two new fields, Forename and Surname.

Now I have to say that this isn't my preferred way of doing this. My preferred way would be to use a Visual Basic (or VB) routine in a macro, but whilst these work for me quite easily in MS Access - the database application that comes with Microsoft Office Professional, I've never managed to get VB macros to work in Excel even when my efforts look exactly like the example in the Help pages. Someone else will have to suggest a fix for that perhaps?

The VB routine would allow me to search for the last space within the name field. Using a simple formula, we have to search for the first space and that's why there's a problem with people who have middle names.

To get over this partly - more specifically to deal with people who have a single middle name or initial - I've used a third new column which I've placed over to the right, out of the way where it doesn't need to be seen or printed. It's doing nothing other than an interim calculation or manipulation of the Full Name field.

I've left a blank column between the working bits of the spreadsheet and this interim field but in reality you may want to hide it away far over to the right - say in column Z or even ZZ!

This interim field searches for the first space and will contain all the text that comes after that first space.

But before we look at the formula for that field let's deal with the simplest formula - that for the Forename field. Before we even do that let's look at the common syntax (the use of characters and the order they must be used) that formulas in Excel have.

Any formula starts with an equals sign (=). This tells Excel that we want it to calculate something rather than treat the following characters as a string of text.

Many formulas use brackets (or parentheses to give them their posh name) to contain any parameters the formula needs to work and use commas (,) to separate each parameter. The formula name tells Excel what to do and the parameters tell it what to do it to and how. A bit like:

=DO-THIS(Do it to this, Do it like this)

Formulas can be nested. That means we can use one formula to calculate the parameters for another formula. To find the Forename from the Full Name we need a formula that does this:

RETURN THE CHARACTERS(from the Full Name, until you reach a space)


For the Forename in Row 3 (so in the cell C3) the formula is:

=IFERROR(LEFT(A3,FIND(" ",A3,1)),"")

There are three different functions here and as with all mathematical formulae you should start by understanding the innermost set of brackets first.

That set contains the parameters for the FIND keyword. The FIND formula counts the character that contains the first character of the string we want to find (the example will make this clear). The syntax for FIND is:

FIND(the string of text you want to find, the string of text you want to find it within, the first character within the original string that you want to start searching from)

Whoa! Too Much! Don't panic yet - I'm about to explain step by step.

Step 1. The string of text we want to find is a space. So in the actual formula a few lines up you see ...FIND(" "...

Step 2. The string of text we want to find the space within, is the Full Name field. So instead of actual text we have a pointer to cell A3. So far we have explained ...FIND(" ",A3...

Step 3. I've put a figure one - 1 - because I want to start searching from the first character. Now; you could argue that there shouldn't be a space until at least the second character so I should have used a 2. But whilst there shouldn't that doesn't mean there won't be a space as the first character. Someone might have wanted to put their first initial and then their surname but not pressed the initial key hard enough. So by using a 1 instead of a 2, we do a simple bit of error trapping.

So that should explain ...FIND(" ",A3,1)... The result of that bit of the formula is the number of the character that contains the space as counted from the left. So as cell A3 contains the text "John Burke" the FIND formula should find the space in character 5 and that is the "result" or "return" of the FIND formula. In the next cell down when considering the string "Seamus O'Leary", the space is the 7th character so the FIND formula returns 7.

Thus as we consider the next most inner bit of the formula - which is the LEFT keyword - I can simplify the formula for you.

Instead of considering:

LEFT(A3,FIND(" ",A3,1))

we can consider it as:

LEFT(A3,5)

because Excel calculates the innermost formula first and works outwards, so once the FIND formula has run the LEFT formula works using the result.

The LEFT formula chops and returns the text from the start (left) of the target string depending on how many characters you want. The syntax for LEFT is:

LEFT(a string of text, the number of characters starting at the left of the string that we want to use)

Again the string of text we want to use is contained in cell A3 so we have LEFT(A3... and the number of characters we want to use (as calculated by the FIND formula) is 5. So LEFT(A3,5) is the same as LEFT("John Burke",5) and the result is "John ". Note that there is a space at the end, because we asked for 5 characters. It won't show so it doesn't matter, but if you wanted to be pedantic (anyone having problems with the formula should ignore this as over complicated) we could have used LEFT(A3,FIND(" ",A3,1)-1) which would have subtracted 1 from the value returned by the FIND.

Ahem! But that's just being a clever clogs!

So that just leaves us with the IFERROR bit of the formula and what that does is it stops Excel from coming up with an error message if there is no space at all.

Basically the syntax for IFERROR is:

IFERROR(I want Excel to do this, but if it finds an error then do this instead)

In the last parameter I've used two double quote marks "" - or in other words I've told Excel that if there is an error, instead of reporting that there's been an error it can show the text within the quote marks. Which is nothing. No text at all. The cell would be empty. Excel isn't good at telling you what's wrong; it just tells you there has been an error.

Without the IFERROR formula if there is no space at all then you just get the dreaded #VALUE! error, which tells you absolutely nothing! See Row 7 in the screen grab.

And so to the surname... Unfortunately there is no way of saying 'Now take the rest' after having done a LEFT formula. But there is a RIGHT formula which does the same as the LEFT only from the rear of the text string.

RIGHT(a string of text, the number of characters starting at the right of the string that we want to use)

Our problem now is that just because we know the position of the space, that still doesn't tell us how many characters we want from the right hand end of the Full Name, because we don't know how many characters there are in the surname.

So we need to know how long the entire string of text is and to do that we use the LEN formula:

LEN(a string of text)

The LEN formula only needs a single parameter and returns a number which is the number of characters contained within the string.

LEN("Fred Bloggs") would return 11. (it's counting the space as a character don't forget)

LEN(A3) returns 10 - because cell A3 contains the text "John Burke"

What we need for the Surname is the length of the Full Name minus the length of the Forename.

So including our error trap use of IFERROR in case there is no space character, our formula is:

=IFERROR(RIGHT(A3,LEN(A3)-FIND(" ",A3,1)),A3)

Break it down from the innermost formula(s) in the nest. That's LEN and FIND. Both return numbers and we are taking LEN formula and then subtracting the result of the FIND formula. That gives us the number of characters to be returned by the RIGHT formula and as long as there is a space existing in cell A3 then we have our final result.

The IFERROR formula this time, instead of returning no text at all, returns all of the Full Name field - assuming that any text with no spaces will be a surname. You can change this round if you keep a spreadsheet of celeb names such as Madonna or Prince!

IFERROR(the main formula,A3)

Now I just need to explain the interim field. The nested formula for the Surname as described above would take everything from the first space. So if there is a middle name or initial then you get that plus the Surname. I've created an interim field with the formula just described and then the Surname field has a formula that is exactly the same but which takes its original text string from the interim field instead of the Full Name field.

You could have as many interim fields as you want, each whittling a middle name or initial out of the final surname, and with no errors even if there is no middle name.

12 such interim columns would let you deal with those unfortunate people whose father named them after the long-forgotten football team in the 1960s or 1970s!

Tuesday, 7 July 2009

Excel: Merge Cells and Multiple Lines in Cells

A couple of related formatting tricks that you can use within a spreadsheet this time.

Let's start with a look at a standard bit of data.

Column A holds the collective heading - the people in Column B in the first four rows belong to Team A and then Team B personnel are held in rows 5 to 8.

We could just repeat the descriptive header by selecting cell A1 and copying it down to the next three rows. But it then starts to become less clear because there is too much confusing text.

So instead we'll merge cells A1 to A4 together as a single cell. In Excel a range of cells is written using the syntax A1:A4 - the colon means "through to".

So we need to select the four cells by clicking into A1 and then click and dragging until the range A1:A4 is selected.

Then we select the Merge & Center whilst tutting slightly at the American spelling and hey presto, the four cells become one whilst at the same time the text has been centred in the horizontal plane. The text though has moved to the bottom of the new cell, to the spot previously occupied by cell A4.

This is because Merge and Center (tut!) is more often used to merge cells next to each other horizontally - grouping a number of column headings for instance.

We can do a couple of things now to format that and they include centring (darn it - the American spelling would look better there...) the text vertically and twizzing it round (Lancashire/technical term for aligning it vertically).

Select cell A1 (the merged cell still has that designation) and right-click the mouse to bring up the dialogue box shown.

Now select Format Cells.

The resulting dialogue window allows us to format lots of things but for now we are interested in the Alignment tab (pointy hand 1).

We can alter the text alignment to centre the text both horizontally and vertically (pointy hand 2) and we can twiz (or is it twizz?) the text (pointy hand 3).

Having clicked the Ok button and resized the cell by double-clicking the right cell wall to get the best fit the result is as shown below.

The pointy hand shows the simple way of aligning text left, right or centred in both horiziontal and vertical planes. The AB button with the little arrow to the right of the pointy hand can be used to twiz text - it opens the same dialogue box we have just used.

That's one way of doing it. Here's the other - which may appear simpler, but may not meet your needs. It's always good to have an alternative!

If whilst typing the names of the team members we used the ALT-Enter key combination we can force cell B1 to accept multiple lines within the single cell.

So we type John Tharmy then hold down the ALT key and whilst it's held down, tap the Enter key. Now without moving from the cell type Sally Vaite and use ALT-Enter again until we read the last name. Now tap the Enter alone as you would normally do and the list of names each occupy a line within the single cell.

Job done!

Friday, 19 June 2009

Excel: Keep Headings in View Whilst Scrolling

A question I've been asked a few times is how to keep headings in view when you scroll down or across a large spreadsheet.

Here I've got a spreadsheet that records the number of views my photos get daily at my Flickr account. Every day I look at the stats on my account and in the spreadsheet I enter the number of views per day and the number of photographs I have stored there. From these two pieces of information the spreadsheet can work out the total number of views by adding the total from the previous day to the daily number of views and the average views per photo by dividing the total views by the number of photos.

However over the course of a year or two there are so many entries (days) that the column headings would normally disappear off the top of the screen when you scroll down.

To stop this happening I've used the Freeze Panes function of Excel to stop the top two rows from scrolling. Those two rows contain the headings and remain on screen whilst the rest of the rows scroll.

To start, select the cell underneath and to the right of the rows and columns you want to keep in view. In my example I only want to freeze the top two rows, not any columns at the left, so the cell I've selected is A3.

Then I select the View tab from the menus at the top.

Finally I select one of the options from the Freeze Panes icon.

Note that once you have frozen some headings, the options change to include an Unfreeze option.

Now I can scroll down as far as I need to and can still see the column headings.