{ 42 comments }

Beyond If and Sum, 15 really useful excel formulas for everyone

in All Time Hits | Featured | Learn Excel | ideas on August 13th, 2008


Excel formulas can always be very handy, especially when you are stuck with data and need to get something done fast. But how well do you know the spreadsheet formulas?

Discover these 15 extremely powerful excel formulas and save a ton of time next time you open that spreadsheet.

1. Change the case of cell contents - to UPPER, lower, Proper

Boss wants a report of top 100 customers, thankfully you have the data, but the customer names are all in lower cases. Fret not, you can Proper Case cell contents with proper() formula.

Example: Use proper("pointy haired dilbert") to get Pointy Haired Dilbert

Also try lower() and upper() as well to change excel cell value to lower and UPPER case

2. Clean up textual data with trim, remove trailing spaces

Often when you copy data from other sources, you are bound to get lots of empty spaces next to each cell value. You can clean up cell contents with trim() spreadsheet function.

Example: Use trim(" copied data ") to get copied data

3. Extract characters from left, right or center of a given text

Need the first 5 letters of that SSN or area code from that phone number? You can command excel to do that with left() function.

Example: Use left("Hi Beautiful!",2) to get Hi

Also try right(text, no. of chars) and mid(text, start, no. of chars) to get rightmost or middle characters. You can use right(filename,3) to get the extension of a file name ;)

4. Find second, third, fourth element in a list without sorting

We all know that you can use min(), max() to find the smallest and largest numbers in a list. But what if you needed the second smallest number or 3rd largest number in the list? You are right, there is a spreadsheet function to exactly that.

Example: Use SMALL({10,9,12,14,26,13,4,6,8},3) to get 8

small-excel-formula-find-nth-small-number-in-list

Also try large(list, n) to get the nth largest number in a list.

5. Find out current date, time with a snap

You have a list of customer orders and you want to findout which ones are due for shipping after today. The funny thing is you do this everyday. So instead of entering the date every single day you can use today()

Example: Use today() to get 08/13/2008 or whatever is today’s date

Also try now() to get current time in date time format. Remember, you can always format these date and times to see them the way you like (for eg. Aug-13, August 13, 2008 instead of 08/13/2008)

6. Convert those lengthy nested if functions to one simple formula with Choose()

Planning to create a gradebook or something using excel, you are bound to write some if() functions, but do you know that you can use choose() when you have more than 2 outcomes for a given condition? As you all know, if(condition, fetch this, or this) returns “fetch this” if the condition is TRUE or “or this” if the condition is FALSE. Learn more about spreadsheet if functions like countif, sumif etc.

Where as choose(m, value1, value2, value3, value4 ...) can return any of the value1,2.., based on the parameter m.

Example: Use CHOOSE(3,"when","in","doubt","just","choose")
to get doubt

Remember, you can always write another formula for each of the n parameters of choose() so that based on input condition (in this case 3), another formula is evaluated.

7. Repetitively print a character in a cell n number of times

You have the ZIP codes of all your customers in a list and planning to upload it to an address label generation tool. The sad part is for some reason, excel thinks zip codes are numbers, so it removed all the trailing zeros on the leftside of the zip code, thus making the 01001 as 1001. Worry not, you can use rept() the extra needed zeros. You can also custom format cell contents to display zip codes, phone numbers, ssn etc.

Example: Use zipcode & REPT("0",5-LEN(zipcode)) to convert zipcode 1001 to 01001

You can use REPT("|",n) to generate micro bar charts in your sheet. Learn more about incell charting.

8. Find out the data type of cell contents

type-formula-arguments-spreadsheetThis can be handy when you are working off the data that someone else has created. For example you may want to capitalize if the contents are text, make it 5 characters if its a number and leave it as it is otherwise for certain cell value. Type() does just that, it tells what type of data a cell is containing.

Example: Use TYPE("Chandoo") to get 2

See the various type return values in the diagram shown right.

9. Round a number to nearest even, odd number

When you are working with data that has fractions / decimals, often you may need to find the nearest integer, even or odd number to the given decimal number. Thankfully excel has the right function for this.

Example: Use ODD(63.4) to get 65

Also try even() to nearest even number and int() to round given fraction to integer just below it.

Example: Use EVEN(62.4) to get 64
Use INT(62.99) to get 62

If you need to round off a given fraction to nearest integer you can use round(62.65,0) to get 63.

10. Generate random number between any 2 given numbers

When you need a random number between any two numbers, try randbetween(), it is very useful in cases where you may need random numbers to simulate some behavior in your spreadsheets.

Example: Use RANDBETWEEN(10,100) may return 47 if you keep trying ;)

11. Convert pounds to KGs, meters to yards and tsps to table spoons

You need not ask Google if you need to convert 156 lbs to kilograms or find out how much 12 tea spoons of olive oil actually means. The hidden convert() function is really versatile and can convert many things to so many other things, except one currency to another, of course.

convert-from-lbs-to-kgs-excel-function

Example: Use CONVERT(150,"lbm","kg") to convert 150 lbs to 68.03 kgs.
Use CONVERT(12,"tsp","oz") to findout that 12 tsps is actually 2 ounces.

12. Instantly calculate loan installments using spreadsheet formula

You have your eyes on that beautiful car or beach property, but before visiting the seller / banker to findout of the monthly payment details, you would like to see how much your monthly / biweekly loan payments would be. Thankfully excel has the right formula to divide an amount to equal payment installments over given time period, the pmt() function.

pmt-calculate-loan-payments

If your loan amount is $125,000,
APR (interest rate per year) is 6%,
loan tenure is 5 years and
payments are made every month, then,

Use PMT(6%/12,5*12,-125000) which tells us that monthly payment is $ 2,416 if you keep trying ;)

Also, if you want to find out how much of each payment is going for principle and how much for the interest component, try using ppmt() and ipmt() functions. As you can guess, even though EMIs or loan installments remain constant, the amount contributed to principle and interest vary each month.

13. What is this week’s number in the current year ?

Often you may need to find out if the current week is 25th week of this year. This is not so difficult to find as it may seem. Again, excel has the right function to do just that.

Example: Use WEEKNUM(TODAY()) will get 33

14. Find out what is the date after 30 working days from today ?

Finding out a future date after 30 days from today is easy, just change the month. But what if you need to know the date thirty working days from now. Don’t use your fingers to do that counting, save them for typing a comment here and use the workday() excel funtion instead. :)

Example: Use WORKDAY(TODAY(),30) tells that Sep 24, 2008 is 30 working days away from today.

If you want to find out number of working days between 2 dates you can use networkdays() function, find out this and a 14 other fun things you can do with excel.

15. With so many functions, how to handle errors

Once you get to the powerful domain of excel functions to simplify your work, you are bound to have incorrect data, missing cells etc. that can make your formulas go kaput. If only there is a way to find out when a formula throws up error, you can handle it. Well, you know what, there is a way to find out if a cell has an error or a proper value. iserror() MS Excel function tells you when a cell has error.

Example: Use ISERROR(43/0) returns TRUE since 43 divided by zero throws divide by zero error.

Also try ISNA() to findout if a cell has NA error (Not applicable).

Give these functions a try, simplify your work and enjoy :)

Subscribe for PHD Email updates and get a free excel e-book with 95 tips & tricks
Delicious Stumble it

« Prev | Home | Simulating Dice throws - the correct way to do it in excel »

Have an Excel Question?

Custom Search

Comments
ben August 13, 2008

Great post. I had never heard of the CHOOSE function. That one is going in my toolbox immediately. I don’t think there’s anything more difficult than nesting IF statements in the Excel formula bar. At least with 2007 they made the bar drop down so you could usually see the whole thing if it was a big one.

Love your blog, been reading for a few months but this is first comment. Keep up the good work.

Sam Krysiak August 13, 2008

Another useful one for processing cell contents:

If you concatenate text and cells containing dates, the date is usually passed to the cell as a numerical value. Use the TEXT function to pass the date as a text string, using the date format of your choice…

=”Date is: “&TEXT(A1, “dd/mm/yyyy”)

Jon Peltier August 13, 2008

1. TRIM also converts excess spaces within a string to a single space, which is very handy with imported data:

TRIM(” abc def “) becomes “abc def”

2. Some functions require the Analysis ToolPak, including RANDBETWEEN, CONVERT, and WEEKNUM.

Chandoo August 14, 2008

@Ben.. thanks, welcome to commenting, I think this is the best place as more good ideas come out of this than the posts often… :)

@Sam.. that is a good tip, may be I will include it in the next issue of 15 functions

@Jon, I didnt know that about trim, thanks for pointing.

Yeah, analysis tool pack is required for few of those functions. I have had it on forever, so didnt realize that. :)

Richard August 16, 2008

Re: Tip #5 (date &/or time)
You all may already know this, but an easy way
to enter the current date in a cell is Ctrl+; then enter, and to enter the current time in a cell type Ctrl+Shift+; then enter.

Jon Peltier September 17, 2008

Tip #7 for Zip Codes:

=TEXT(A1,”00000″)

Chandoo September 17, 2008

@Richard… thanks for that. :)

@Jon .. This is sweet, thanks very much. Often I use the Rept() way of doing this.. I am sure TEXT() is easier to use when you know the format up front.

Bill November 12, 2008

i’m making up a form for a friends business and on a second copy of that same page i using a formula to copy data in particular cells. the problem i have is that i’m getting a bunch of “0″ ont he copy if there isn’t data on the first form. how can i get rid of that “0″?

Chandoo November 12, 2008

@Bill.. Welcome to PHD. Thanks for asking the question.

When you use references you can wrap it in an if clause.

For eg. instead of saying =Sheet1!A2
you can write: =if(Sheet1!A2=”",”",Sheet1!A2)
that way, when ever the reference is empty you will force excel to show empty space instead of ZERO.

Ketan November 13, 2008

@Bill / Chandoo :
You may untick the zero values from menu==>tool==>option==>view

Leonel Quezada January 2, 2009

Chandoo:
I think NA is for “Not available”. (Tip 15).

Loula February 9, 2009

Nice Chandoo :D
Chandoo :( need your help :(
am having an excel sheet it is actually a request sheet that provide an ID.. this ID I have to formlize it each day i want to ask for a request… the problem I just hate this way I need to find a way to make this ID automatically appear with a new serial number each time I add new sheet!!!!
note the ID number has to be formlized by this way: ddmmyy/###
how could I do it Chandoo?? :( need your help :’(

Chandoo February 10, 2009

@Loula.. thanks and welcome to PHD. Let me see if we can help you.

automatically incrementing the number whenever you use the formula is possible through circular references. Even automatically getting the current date while keeping the old date values intact uses circular references in formulas. These are slightly complicated formulas and hence I don’t recommend them for day to day uses.

A better solution could be to use macros, write once and run whenever you need a new ID to be generated and pasted in the current cell. Let me know if you are interested, I can either help you on this as a consulting engagement or provide you some general guidelines through comments.

I am sorry, but I dont know anything else that is better, may be one of our readers do…

Bobby February 10, 2009

Chandoo, I need your help too. I downloaded the gauge sample and do not know how to replicate it. How did you make the pointer? I am pretty sure I can figure out the arch, but the pointer I am lost. Awesome site!!

Loula February 12, 2009

Yes Chandoo it seems to be better than the way that I do :(
thanks alot Chandoo and wait your guidlines :)

Chandoo February 16, 2009

@Bobby: I suggest you to read this article : http://chandoo.org/wp/2008/09/09/excel-speedometer-chart-download/

and see the sample download provided there. If you still have any doubts, feel free to ask me.

@Loula: Are you looking for some general info on circular references? if so, try this: http://chandoo.org/wp/2009/01/08/timestamps-excel-formula-help/

If you need a more specific solution, drop another comment, I am sure one of our readers or me can respond with a good answer.

Loula February 26, 2009

Yes I got some example,, but till now I could not find a way to write my forumla :(
I could do the date format but how could I put the serial number that comes automatically whenever I add new sheet??!!

Chandoo February 26, 2009

@Loula: hmm.. there are few ways you could do that. (1) obviously using VBA to autogenerate a sequence number and place it cell, say B3 whenever a new sheet is added.
(2) using CELL() function in each sheet, CELL(”filename”) would tell you the entire file path along with sheet name. Then extract the sheet name using a formula like, =RIGHT(CELL(”filename”),LEN(CELL(”filename”))-FIND(”]”,CELL(”filename”))). Now use this name to derive the sequence number. If you are using default naming structure, then your sheet names would be sheet 1, sheet 2, sheet 3, … , sheet 99 etc.

Let me know if you need further help :)

Paul March 11, 2009

I’m kinda new to Excel and I need some help with a formula.
I need to calculate Drive time and actual work time in units if 1 unit=5 minutes.

Chandoo March 12, 2009

@Paul: Welcome to Excel and PHD… :)

You can do that by using a formula like: =A3/5, assuming A3 has drive time in minutes, wherever you enter this formula it will give you the units
use the same logic for calculating work time. You may want to check our excel formula help section: http://chandoo.org/wp/excel-formula-helper-index-cards/ to learn more about formulas in plain English.

Loula March 13, 2009

Chandooooo :’(
I tried many ways to do it but really couldn’t do it :(
please if you do not mind give me step by step
sorry for bothering you :(

Chandoo March 15, 2009

@Loula.. Sure, give me sometime… (I am sorry, but I am in between few important things and cant really take out time… I do appreciate your patience.. If any of our commenters can help Loula, I will be very thankful to you..)

al m3tasem March 24, 2009

In Cell A1 I Typed :
=PROPER(”thank you chandoo very much”)
and It displayed
Thank You Chandoo Very Much :)

Chandoo March 25, 2009

@Al… thank you so much.. that is soo sweet.. :)

Loula March 28, 2009

Ok wait you to finish :) thank you

Chandoo March 31, 2009

@Loula: I feel very unfortunate for not being able to help you on time. I have moved to Sweden from a Sunny place in India and found myself with very limited internet access and extremely busy work schedule. I am not sure when I will be able to get back to you… but if you find a solution, share it with us.

Eternal glory awaits you…

Sharon April 15, 2009

Hi - complex issue I think: I have an Xcel doc with multiple worksheets for weeks of the month. It is a timesheet. I want to summarize total time in the month (pulling from multiple worksheets) based on a project number - which is variable, but always in the same column on each worksheet. The project number is in column D, which is totaled into column M for each weekday entry. The biggest stumbling block I see is the project number will not always appear on the same row. So I want a consolidated sum from column M where column D equals a specific text/numerical string from multiple worksheets. Does this make sense? Is it possible? Thanks!

Varun April 16, 2009

Hy guys. I am new to excel too.

Lets say there is a column which has 1 or more names, separated by commas. My requirement is that in the next column, a count of number of names is displayed.i.e. one can count the number of commas. I am unable to implement this.Please help.If you have any other suggestion to count,then also please share it.

Chandoo April 19, 2009

@Sharon: Welcome to PHD and thanks for asking a question. I have taken an extended easter break to catch up on few things at home and now back online :)

coming to your question, yes, you can use excel to solve your problem. You need to use 3d references and sumif(). a 3d reference refers to same range across several sheets. See this: http://chandoo.org/wp/2009/02/04/satisfaction-surveys-excel/ and http://chandoo.org/wp/2008/11/12/using-countif-sumif-excel-help/ for more help.

I am not giving step by step instructions as it is a peculiar problem. But I am sure you can put the pieces together and solve this. Let me know if you hit any road block.

Chandoo April 19, 2009

@Varun: Welcome to excel.

You can count the number of commas (or any other symbol) in a cell using this formula: =len(”a,b,c,d”)-len(substitute(”a,b,c,d”,”,”,”"))
so, if you want the number of names in the cell, just add 1 to the above formula.

Let me know if you have some problems implementing this.

Varun April 20, 2009

@Chandoo.

Thanks for the help mate. With a little modification , it worked.

=IF(J423″”,LEN(J423)-LEN(SUBSTITUTE(J423,”,”,”"))+1,0)

However, as my motive is to count the no. of words, it’ll give an extra count,if a comma is inserted at the end.

Thanks again.Will be bugging in the future as n when new issues will pop.

Ron June 15, 2009

Chandoo,
Just found this excellent blog, and have already incorporated a couple ideas into my work.
One small note on the example used in #7 - I believe it should be =REPT(”0″,5-LEN(zipcode)) & zipcode and not
=zipcode & REPT(”0″,5-LEN(zipcode)) as you want to pad the start of the string and not the end.

thanks again.

RSS feed for comments on this post. TrackBack URI

Leave a comment

   Name (required)

   E-mail (required, never displayed)

   URL


Join Our Community