excel formulas

25
Question: I need to do the following and have a problem figuring out what function to use and how to use it: If Bob T is in 6 classes with 6 different grades in a room of 30 students with different first and last names and the names are put in aphbettical order (Bobs name will not be in the same row each time) How would I only collect the grades of Bob T? I have tried to use filter and dsum but failed given some conditions. I really appreciate it if you can be of any help. Answer: It sounds like you need to use the VLOOKUP function. Let's assume that the names of the students are found in Column A and the Grades in Column B. In this case, you function will look like this: =VLOOKUP("Bob T",$B1:$B100,2,FALSE) With the vlookup formula, it doesn't matter on which row the data is. This will retrieve the grade in one class. Adapt this formula for the rest of the classes and you should be good to go. Tags: VLOOKUP Question: how do I create a condition for date cells to change color when todays date is 30 days away from date in cell and past the date in the cell? Answer: I assume your data looks something like this:

Upload: devangimehta

Post on 11-Nov-2014

608 views

Category:

Documents


5 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Excel formulas

Question:

I need to do the following and have a problem figuring out what function to use and how to use it: If Bob T is in 6 classes with 6 different grades in a room of 30 students with different first and last names and the names are put in aphbettical order (Bobs name will not be in the same row each time) How would I only collect the grades of Bob T? I have tried to use filter and dsum but failed given some conditions. I really appreciate it if you can be of any help.

 

Answer:

It sounds like you need to use the VLOOKUP function.

Let's assume that the names of the students are found in Column A and the Grades in Column B.

In this case, you function will look like this:

=VLOOKUP("Bob T",$B1:$B100,2,FALSE)

With the vlookup formula, it doesn't matter on which row the data is.

This will retrieve the grade in one class. Adapt this formula for the rest of the classes and you should be

good to go.

Tags: VLOOKUP

Question:

how do I create a condition for date cells to change color when todays date is 30 days away from date in cell and past the date in the cell?

Answer:

I assume your data looks something like this:

Page 2: Excel formulas

To highlight the cells that are 30 days or more before today's date, you should select cell B2 and use the

following conditional formatting rule:

Then, copy the rule to the other cells using the brush tool (format painter) and you will get this result:

Page 3: Excel formulas

Tags: Conditional Formatting

Question

I have a column set up with conditional formatting to color the cell w/in the column a certain color depending on a certain word. Ex)"Post" = Green, "Select"=Blue, "Deny"=Red, "Hold"=Yellow. I need the entire row to change the same color as the one cell w/out merging. How can I format the color to the whole row depending on the status of the one cell?

Answer:

If you select 'conditional formatting' -> 'manage rules' you'll see that all your rules apply to ranges $F:$F (just

one column).

If you change them to apply to $A:$F, you get the conditional formatting to apply to the entire row.

Question:

How do I make a cell change colors once it hits a certain number?

Answer:

By making a simple conditional formatting rule...

1.  Select the cell

Page 4: Excel formulas

2. From the Home ribbon select 'Conditiional Formatting'

3. Then select 'Highlight Cell Rules'

4. Then select 'Greater than'

5. Then enter  your number (minus one).

6. Select how you want to higlight the cell and...

7. Press OK

And you're good to go.

Tags: Conditional Formatting

Question:

how to rank value with name result? for example: I have player name in A1:A5, score in B1:B5, and I want to have rank based on higher score with player name on it.

Answer:

Put the following formula in cell C1

=RANK(B1,$B$1:$B$5)

Then copy the formula to cells C2:C5.

And finaly, sort the table on column C.

Tags: RANK

Question:

I have a list of state abbreviations and in the column next to it I need to have the time zones that correspond. How can I have the time zone column prepopulate after I enter the state abbreviation?

Answer:

Page 5: Excel formulas

You should use the VLOOKUP function.

The following image shows a list of state abbreviations and corresponding time zones.

The sheet automatically translates the state abbreviation in cell D4 to the time zone in E4 by using the

following VLOOKUP formula

=VLOOKUP(D4,$A$1:$B$17,2,FALSE)

Its important to note that the range the VLOOKUP function uses is an absolute reference. You almost always

need to use absolute reference when defining the lookup array because while the formula is likely to be

copied and the lookup value reference may change, the lookup array range almost never changes.

Tags: VLOOKUP

Not whatyou're looking for?

Page 6: Excel formulas

Response time: 3 minutes

Question:

I have created a vlookup that when copied gives me different results than the manually entered formula. When I manually enter the formula, it works perfect; this is a document with 2000+ rows so manually entering the formula is not an option. I have never encountered this before. Any suggestions?

Answer:

It sounds like a relative reference problem. This happens a lot with VLOOKUPs.

Your formula probably looks something like this:

=VLOOKUP(E2,A2:C9,2,FALSE)

If you copy this formula one cell down it will look like this:

=VLOOKUP(E3,A3:C10,2,FALSE)

Note that E2 changed to E3 which is good, you want the formula to lookup the value in the next row But...

The lookup range also changed to A3:C10, which is not good. Eventually the lookup range will change so

that the original lookup array is not even included and than you'll get error values.

To prevent this, you need to turn the lookup range into an absolute reference range, like this:

=VLOOKUP(E2,$A$2:$C$9,2,FALSE)

This way you can copy the formula and have the reference to the lookup value change without changing the

lookup array.

 

Tags: VLOOKUP

Page 7: Excel formulas

Question:

I have 5 columns and 50000 rows, i want data from all 5 columns into the 6th column in the format of SQL Insert query; e.g. insert into table1 values('a1','b1','c1', 'd1','e1') for the first row. and want to repeat the same for all rows in the excel.

Answer:

Well this is a simple task of concatenating strings. The following formula will do the trick:

="Insert into table1 values('" & A1 & "','"& B1 & "','" & C1 & "','" & D1

& "','" & E1 & "')"

Once you have this formula in Cell F1, copy it to Cells F2:F50000 and the formula will automatically adjust to

create the right insert statements for you.

The Excel Power function

The power function is used (as you have probably guessed) to raise a number to a power.

For instance, the formula:

=Power(10,2) is 10*10 (can be written 102) which equals 100

=Power (2,3) is actually 2*2*2 (or 23), which equals 8

Note

Excel also includes the operator '^' for the Power() function.

So instead of writing:

=Power(10,2)

You can write:

=10^2

Page 8: Excel formulas

The power function can be used in many ways, but perhaps it's most well known use is with compound interest rate.

The following sheet shows the return on investment on a $5000 investment carrying a 5% interest rate over different

investment periods (column C).

You calculate the return on investment by raising the interest rate by the power of the time period then multiplying it

with the original investment sum.

This will translate to the following Excel formula:

=A2*POWER(B2,C2)

Note

To get a feel of the Power() function try the following exercise:

Page 9: Excel formulas

Open a new sheet and simulate the growth rate of an imaginary virus. The rules of the game are very simple. Each

generation the virus splits into 2 new viruses.

Put the number 2 in cell A1

Put the number of generations (start with 5) in cell A2

And put the formula =Power(A1,A2) in B2

B2 will show you how many viruses there are after 5 generations.

Now play with the number of generations and see how the results change.

Excel ROUNDUP, ROUNDDOWN and ROUND functions

In the previous example we calculated the return on investment by using the power function. If you look at the results

of the calculation on column D, you'll see that they show 5 digits after the decimal point.

Page 10: Excel formulas

While showing numbers after the decimal point is certainly more precise, it also makes reading the sheet much

harder because of all those extra numbers.

One of the ways to eliminate (or reduce) the digits after the decimal point is to use the ROUNDUP(), ROUNDDOWN()

and ROUND() functions.

As you probably gathered from its name, the ROUNDUP() function will round any given number up to the next round

number.

What's interesting is that ROUNDUP() also lets round up to a specific number of decimal points. That's done by

passing the number of decimal points you want to round up to as the second parameter (0 meaning to round up to

the closest whole number, 1 meaning there will be one digit after the decimal point, and so on).

For Example:

=ROUNDUP(18.23,0) will return 19

Page 11: Excel formulas

While

=ROUNDUP(18.23,1) will return 18.3

The ROUNDDOWN() acts exactly the same way as the ROUNDUP() function except it will round the number down to

the previous round number (with a specified number of digits).

For Example:

=ROUNDDOWN(18.23,0) will return 18

And

=ROUNDDOWN(18.23,1) will return 18.2

The ROUND() function will round to the closest number (given a specific number of digits).

For example:

=ROUND(18.23,0) will return 18

While

=ROUND(18.51,0) will return 19

Note

What do you think will the function =ROUND(18.5,0) return?

Will it return 19 or will it return 18?

Open Excel and check if your answer was correct.

Excel CEILING and FLOOR functions

The FLOOR() and CEILING() function are similar to the ROUND functions but serve a slightly different purpose.

Page 12: Excel formulas

The CEILING function receives two parameters (let's call them A and B) and returns the multiple of B that's both

closest to and larger than A.

For instance

=CEILING(10,3)

Will return 12 since 12 is the closest multiple of 3 which is also larger than 10.

Imagine you wanted to calculate how many tables you should arrange for your wedding.

You know how many people you plan to invite to the wedding. And you know that each table seats 14 people.

The following formula will reveal the answer in a blink:

=CEILING(A1,14)/14

Enter the number of invitees into cell A1 and you've got your answer.

Page 13: Excel formulas

You can reach the same result by using the following formula...

=FLOOR(A1,14)/14+1

Can you explain why?

Excel Count Function

Page 14: Excel formulas

Counting is one of the things Excel does best. And if you probe the help files you'll find 5 different counting functions.

But let's turn to the basic COUNT() function.

The COUNT() function receives a range and returns the number of the numeric value found in that range.

For example, if we wanted to calculate the average of the numbers that appear in a certain range (assuming that we

didn't use the AVERAGE() function), we could use the following formula:

Note

The COUNT() function can be used to count the numbers in a column even if you don't know the what will be the last

cell in the column. This is achieved by passing the entire column as a parameter to the count function in the following

way:

Page 15: Excel formulas

=COUNT(A:A)

I need to create a formula that shows when a value from a drop down list is selected it will pre-populate in other cells information from another list

Answer:

You'll need to use the VLOOKUP function. In the following screen shot you can see that the Job field is auto-

filled after the name of the employee is selected form the drop down list.

This is the formula used to achieve this:

=VLOOKUP(B10,B3:C7,2,FALSE)

Question:

I need to do the following and have a problem figuring out what function to use and how to use it: If Bob T is in 6 classes with 6 different grades in a room of 30 students with different first and last names and the names are put in aphbettical order (Bobs name will not be in the same row each time) How would I only collect

Page 16: Excel formulas

the grades of Bob T? I have tried to use filter and dsum but failed given some conditions. I really appreciate it if you can be of any help.

 

Answer:

It sounds like you need to use the VLOOKUP function.

Let's assume that the names of the students are found in Column A and the Grades in Column B.

In this case, you function will look like this:

=VLOOKUP("Bob T",$B1:$B100,2,FALSE)

With the vlookup formula, it doesn't matter on which row the data is.

This will retrieve the grade in one class. Adapt this formula for the rest of the classes and you should be

good to go.

Tags: VLOOKUP

Question:

I'm trying to work out percentage increases but when one of the cells has 0 in it its giving me DIV/0 error How do i stop this?

Answer:

To avoid showing the DIV/0 error you should use the ISERROR() function like this:

=IF(ISERROR(A1/B1),"",A1/B1)

The function above will an empty value when the division formula returns an error.

Tags: IF ISERROR

Page 17: Excel formulas

how do I create a condition for date cells to change color when todays date is 30 days away from date in cell and past the date in the cell?

Answer:

I assume your data looks something like this:

To highlight the cells that are 30 days or more before today's date, you should select cell B2 and use the

following conditional formatting rule:

Page 18: Excel formulas

Then, copy the rule to the other cells using the brush tool (format painter) and you will get this result:

Question:

I would like to have my data in excel automatically sort every time I open it to the preference I have pre-set. I would rather this instead of always having to select my data, hit data, sort, and etc. How would I do this?

Answer:

This can be done by using a VBA macro. For example, if you have the following data:

Page 19: Excel formulas

 

The following code will run the sorting subroutine when the workbook is opened:

Private Sub Workbook_Open()

    Call SortByRank

End Sub

And this subroutine will enable the autofilter functionality, clear all existing filters and then filter the data on

column B:

Sub SortByRank()

    Range("B4").Select

    Selection.AutoFilter

    

    ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Clear

    ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add _

        Key:=Range("B1:B6"), SortOn:=xlSortOnValues, _

        Order:=xlAscending, DataOption:= _

        xlSortNormal

    With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort

        .Header = xlYes

        .MatchCase = False

        .Orientation = xlTopToBottom

        .SortMethod = xlPinYin

        .Apply

    End With

End Sub

And the end result will be this:

Page 20: Excel formulas

Tags: VBA

Question:

I have created a vlookup that when copied gives me different results than the manually entered formula. When I manually enter the formula, it works perfect; this is a document with 2000+ rows so manually entering the formula is not an option. I have never encountered this before. Any suggestions?

Answer:

It sounds like a relative reference problem. This happens a lot with VLOOKUPs.

Your formula probably looks something like this:

=VLOOKUP(E2,A2:C9,2,FALSE)

If you copy this formula one cell down it will look like this:

=VLOOKUP(E3,A3:C10,2,FALSE)

Note that E2 changed to E3 which is good, you want the formula to lookup the value in the next row But...

Page 21: Excel formulas

The lookup range also changed to A3:C10, which is not good. Eventually the lookup range will change so

that the original lookup array is not even included and than you'll get error values.

To prevent this, you need to turn the lookup range into an absolute reference range, like this:

=VLOOKUP(E2,$A$2:$C$9,2,FALSE)

This way you can copy the formula and have the reference to the lookup value change without changing the

lookup array.

 

Tags: VLOOKUP

Question:

hi, i have a macro that inserts a row every one minute and populates the first cell of that row with the price of a stock. I'm trying to apply an "average" function to the first 5 cells as the prices come in. However, the range of the average is also moving down as new rows are inserted. The objective is to anchor the range of the average function even as new rows are added. thanks.

Answer:

The easiest way to anchor a range would be to use the INDIRECT function.

In your case the formula would be something like this:

=AVERAGE(INDIRECT("A1:A5"))

This way, even if you insert new rows, the range won't change

Question:

Can I make excel look for the highest value in a colum and then second highest and so forth?

Answer:

To find the highest values in a column you can use the LARGE function.

for example if you want to find the highest value in column A, you'll use the following formula:

Page 22: Excel formulas

=LARGE(A:A,1)

To find the second highest value, just change the 1 in the previous formula to 2., like so:

=LARGE(A:A,2)

Tags: LARGE

Question:

How do I sum cells greater than a value even if there is a zero cell in between two cells greater than the value.

Answer:

To sum cells that are greater than a value you should use the SUMIF() function.

For example, the following formula will sum all the values that are greater than 100 on column A

=SUMIF(A:A,">100")

And it doesn't matter if there is a cell that contains zero or any other value in that range.

Tags: SUMIF

I am trying to extract out a name within a cell. For example: 613490 Chong Susanna,5087321900 In the above cell, I want to pull out just the name.

Answer:

Luckily, your string contains a space before the name and a comma after it. This makes it easy to find where

the name starts and it's length so you can 'cut' it out with the MID() function.

The following formula will extract the name for you:

=MID(A1,FIND(" ",A1)+1,FIND(",",A1)-FIND(" ",A1)-1)

Tags: MID FIND

How can I average cells but only ones with numbers greater than 0?

Answer:

Page 23: Excel formulas

By using the AVERAGEIF function

The following formula will return the average of all the cells that are bigger than 0 in range A1:A7 :

=AVERAGEIF(A1:A7,">0")