Showing posts with label Formula. Show all posts
Showing posts with label Formula. Show all posts

Monday, January 2, 2012

Formula Forensics 006. Palindromes

Chandoo wrote a post in August 2011 where he looked at determining if a cell contained a palindrome.


Chandoo presented a formula for determining if a cell; C1; contains a palindrome:


=IF(SUMPRODUCT((MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1)=MID(C1,LEN(C1)-ROW( OFFSET($A$1,,, LEN(C1) )) +1, 1))+0)=LEN(C1),"It’s a Palindrome","Nah!")


And then Chandoo challenged everyone:


How does this formula work?


Well, that is your weekend homework.


So today we’re going to complete our homework and pull apart the above formula and see what makes it tick.


Download the example file so you can follow along with a worked example, Excel 97-2010.


In a blank worksheet enter


C1: “Chandoo” without the brackets


D1: =IF(SUMPRODUCT((MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1)=MID(C1,LEN(C1)-ROW( OFFSET($A$1 ,,, LEN(C1)))+1,1))+0)=LEN(C1),"It’s a Palindrome","Nah!")


In the example below we will work on two words:


Firstly, “Chandoo” which is clearly not a Palindrome


and Secondly, “Radar” which is a Palindrome


The main structure of this formula is that it is a simple If () function.


The Excel If() function is defined by 3 parts


=If(Condition, Value if True, Value if False)


Our Formula is


=IF( SUMPRODUCT(( MID(C1, ROW( OFFSET( $A$1,,,LEN(C1))), 1) = MID(C1, LEN(C1) - ROW( OFFSET( $A$1,,,LEN(C1))) + 1, 1)) + 0) = LEN(C1), "It’s a Palindrome", "Nah!")


Condition:                 SUMPRODUCT((MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1) = MID(C1, LEN(C1) - ROW(OFFSET($A$1,,,LEN(C1)))+1,1))+0)=LEN(C1)


Value if True: "It’s a Palindrome"


Value if False: "Nah!”


Lets not waste time on the two Values if True/False as they are purely a message to the user, the real work happens in the Condition part of the If() function.


The Condition does all the work: SUMPRODUCT((MID(C1,ROW( OFFSET($A$1,,, LEN(C1))),1) = MID(C1, LEN(C1)-ROW( OFFSET($A$1,,,LEN(C1)))+1,1))+0)=LEN(C1)


Is a Sumproduct and a Len


That is the formula is doing a calculation of the sumproduct of some inner calculations and comparing the answer to the length of the contents of cell: C1 in the example of "Chandoo" = Len(C1) = 7


SUMPRODUCT(( MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1)= MID(C1, LEN(C1)-ROW( OFFSET($A$1,,, LEN(C1)))+1,1))+0)=LEN(C1)


Lets now look at the two inner calculations:


MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1)


Copy this calculation into E7


= MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1) Don’t press Enter, press F9


(If using the example file goto cell E9, Press F2 and then F9)


Excel will return {"C";"h";"a";"n";"d";"o";"o"} Don’t press Enter, press Esc when ready


It is an Array of the letters in the cell C1


Now do the same for the second part of the equation:


Copy this calculation into E8


= MID(C1, LEN(C1)-ROW(OFFSET($A$1,,,LEN(C1)))+1,1) Don’t press Enter, press F9


Excel will return {“o”;”o”;”d”;”n”;”a”;”h”;”C”}


You will notice that this array is the reverse of the word in C1


We will come back to how these two equations work in a minute or two


But note that we now have


Sumproduct(({"C";"h";"a";"n";"d";"o";"o"}={“o”;”o”;”d”;”n”;”a”;”h”;”C”})+0)


We can evaluate the inner part of this to see what happens


Copy this calculation into E10


={"C";"h";"a";"n";"d";"o";"o"}={“o”;”o”;”d”;”n”;”a”;”h”;”C”} Don’t press Enter, press F9


Excel will return an Array {FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE}


This means that only the 4th letter or “n” in Chandoo is the same forward and backwards.


Looking at the next bit


Copy this calculation into E12


=({"C";"h";"a";"n";"d";"o";"o"}={“o”;”o”;”d”;”n”;”a”;”h”;”C”})+0 Don’t press Enter, press F9


Excel will return {0;0;0;1;0;0;0}


Excel has converted the false/True array above into an array of 0's and 1's


Finally in E14 evaluate:


=Sumproduct({0;0;0;1;0;0;0})


Is evaluated and Excel adds up all the numbers returning a 1 as the answer.


So the original equation :


=IF(SUMPRODUCT((MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1)=MID(C1,LEN(C1)- ROW( OFFSET($A$1,,, LEN(C1))) +1,1)) +0 )=LEN(C1),"It’s a Palindrome","Nah!")


Is simplified as


=IF( 1 = LEN(C1),"It’s a Palindrome","Nah!")


Now C1 has the Word “Chandoo “ in it which is 7 letters long


=IF( 1 = 7,"It’s a Palindrome","Nah!")


So the If() function returns the False answer of “Nah!”


If we place a Palindrome such as “Radar” in C1 and skip backwards to the


SUMPRODUCT(( MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1)= MID(C1, LEN(C1)-ROW(OFFSET($A$1,,,LEN(C1)))+1,1))+0)=LEN(C1)


Section , Evaluating each part again we see


E21: MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1)


Evaluates to {"R";"a";"d";"a";"r"}


And


MID(C1, LEN(C1)-ROW(OFFSET($A$1,,,LEN(C1)))+1,1)


Evaluates to: {"r";"a";"d";"a";"R"}


And


( MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1)= MID(C1, LEN(C1)-ROW(OFFSET($A$1,,,LEN(C1)))+1,1))


Evaluates to: {TRUE;TRUE;TRUE;TRUE;TRUE}


With


SUMPRODUCT(( MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1)= MID(C1, LEN(C1)-ROW(OFFSET($A$1,,,LEN(C1)))+1,1))+0)


Evaluating to: 5


Which is clearly equal to the length of the word “Radar” and so the If() function returns “It’s a Palindrome”


But how do the middle bits


MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1)


and


MID(C1, LEN(C1)-ROW(OFFSET($A$1,,,LEN(C1)))+1,1)


Work?


The two equations are effectively the same


The first works left to right and extracts each letter one at a time


The second works right to left and extracts each letter one at a time


How Does


=MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1) F9


Evaluate to {"C";"h";"a";"n";"d";"o";"o"}


=MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1) F9


Is a simple Mid() function which takes the 1 Character at position ROW(OFFSET($A$1,,,LEN(C1))) from the contents of C1


What is ROW(OFFSET($A$1,,,LEN(C1)))


Is used to return an array of numbers from 1 to Len(C1) in this case 7


eg: {1;2;3;4;5;6;7}


So in E16 enter =ROW(OFFSET($A$1,,,LEN(C1))) and press F9


Excel evaluates it to {1;2;3;4;5;6;7}


So the function =MID(C1,ROW(OFFSET($A$1,,,LEN(C1))),1)


Returns the 1st, 2nd. 3rd, 4th, 5th, 6th & 7th characters from C1 as an Array


=ROW(OFFSET($A$1,,,LEN(C1)))


Takes the Row of the range defined by the Offset Function


Note that OFFSET($A$1,,,LEN(C1)) is a simple Offset that sets up a range


The excel Offset Function is defined as


=Offset(Reference, Rows, Columns, [Height], [Width])


In our example


=OFFSET($A$1,,,LEN(C1))


Will return a Range which is referenced to A1, has no Row or Column offset and is the length of cell the contents of Cell C1


Effectively returning a range A1:A7


Because this is all in an Sumproduct formula, Excel evaluates this formula for each value in the Range


And so


=ROW(OFFSET($A$1,,,LEN(C1)))


evaluates it to


{1;2;3;4;5;6;7}


Which is then used extract the characters from the word in C1 into an Array as {"C";"h";"a";"n";"d";"o";"o"}


A similar process applies to the second half of the two equations


MID(C1, LEN(C1)-ROW(OFFSET($A$1,,,LEN(C1)))+1,1)


Except that it is evaluated from the Right to Left of the Word in C1 by use of the


LEN(C1)-ROW(OFFSET($A$1,,,LEN(C1)))+1


In the Mid Equation


So in summary we use Sumproduct to compare two Arrays, which contain the word and the word reversed, to each other. The Sumproduct counts the number of common matches and then this is compared to the length of the word.


If the two match the word is a Palindrome.


You can download a copy of the above file and follow along, Download Here.


You can learn more about how to pull Excel Formulas apart in the following posts which are all included in the Formula Forensic Series:


I am running out of ideas for Formula Forensics and so I need your help.


If you have a neat formula that you would like to share and explain, try putting pen to paper and draft up a Post as Luke did in Formula Forensics 003 or like above.


If you have a formula that you would like explained but don’t want to write a post also send it in to Chandoo or Hui.



RSS feed for comments on this post. TrackBack URI



View the original article here

Wednesday, December 28, 2011

Formula Forensics No. 005 – Zebras and Checker-Boards

This week in Formula Forensics we’ll look at, Zebra Stripes and Checker-board Conditional Formatting.


This idea is inspired by a number of posts over the past few years asking about zebra stripes but specifically BobR who in in June 2011, also asked about Checkerboards in the post: Want to be an excel conditional-formatting Rock Star, Comment No. 154.


I got the conditional format for alternating row and column colors,


Is there a conditional format to make it a checkerboard whereas the cell A2 will remove either the conditional for the row or column and then alternately to A4, B1, B3 etc?


Chandoo responded fairly quickly with this Conditional Formatting formula:


=IF(MOD(ROW(),2)=1,MOD((ROW()-1)*8+COLUMN(),2)=0,MOD((ROW()-1)*8+COLUMN(),2)=1)


Unbeknownst to Chandoo I posted this about a minute later:


=ISODD(ROW()+COLUMN())


Both formula correctly answer BobR’s question.


So today we’re going to pull apart Zebra Stripes and Checker Boards and see what makes them tick.


As always you can follow along in a download file here: Download File.


Zebra Stripes as Conditional Formatting is simply applied using a simple formula within Conditional Formatting.


=MOD(ROW(),2)=0


Conditional Formatting requires a formula that returns a boolean “True” to apply a format or a Boolean “False” to not Apply a format.


So the formula is better read as: If MOD(ROW(),2)=0


And  If MOD(ROW(),2)=0, the formula will evaluate as True


This is best evaluated as 3 columns on a worksheet.



In cells


B5:B10 The formula =Row() returns the Row Number


C5:C10 The formula =Mod(Row() ,2) returns the Mod of Row Number, divided by 2


The Mod function returns the remainder of the division of the Row Number divided by 2,


So in Row 5, Mod(Row(),2) = Mod(5, 2) = 5/2 = 2 Remainder 1 = 1


and in Row 6, Mod(Row(),2) = Mod(6, 2) = 6/2 = 3 Remainder 0 = 0


D5:D10 The formula =Mod(Row() ,2)=0 checks the remainder against the value 0


This is what evaluates to either True or False depending on the Row number.


Where the Values are True the Format will be applied (Even Rows)



The Conditional Formatting can be applied to Odd Rows If the Formula is slightly altered


=Mod(Row() ,2)=1



Similarly the formatting can be applied to Columns using


=MOD(COLUMN(),2)=0/1



RobR received two responses to his Checker-Board Conditional Formatting request.


=IF(MOD(ROW(),2)=1,MOD((ROW()-1)*8+COLUMN(),2)=0,MOD((ROW()-1)*8+COLUMN(),2)=1)


and


=ISODD(ROW()+COLUMN())


Lest see what’s inside these two formula.


This is a simple If Formula with 3 components


=IF(MOD(ROW(),2)=1,MOD((ROW()-1)*8+COLUMN(),2)=0,MOD((ROW()-1)*8+COLUMN(),2)=1)


If Condition        MOD(ROW(),2)=1


Value if True:     MOD((ROW()-1)*8+COLUMN(),2)=0


Value if False:    MOD((ROW()-1)*8+COLUMN(),2)=1


The If Condition is already known to us, as it’s the same formula used in the Zebra Stripes above.


It evaluates to True when it is on an Odd Row.


So when it is an Odd numbered Row Excel will look at MOD((ROW()-1)*8+COLUMN(),2)=0


And when it is an Even numbered Row Excel will look at MOD((ROW()-1)*8+COLUMN(),2)=1


We can notice that these are the same formulas which have a different ending of =0 and =1


MOD((ROW()-1)*8+COLUMN(),2)=0


This section Takes each Row subtracts 1 and then multiplies this number by 8. This can be expressed as simply as saying multiply the Row * 8.


This will always return an Even Number and could have been simplified to Row()*2


MOD((ROW()-1)*8+COLUMN(),2)=0


The next bit adds the column number to the previous Even Number.


So now this part will be Odd when the column is Odd and Even when the column is Even.


MOD((ROW()-1)*8+COLUMN(),2)=0


The remainder of the formula is the same as the Zebra Stripes formula.


An Odd Number (Odd Columns) in the section above will return a 1 as the result of =Mod(Odd,2)


An Even Number (Even Columns) in the section above will return a 0 as the result of =Mod(Odd,2)


When evaluated against 0 will return True for Even Columns and False for Odd Columns.


Now the exact same happens in the False section of the If formula except that it is evaluated against 1.


I tackled this problem from a different direction to Chandoo.


Knowing that Even + Even = Even and Even + Odd = Odd and that the row and Column Numbers increase in each direction by 1 each Row/Column, it was simply a matter of adding the Row and Column numbers together and checking if it was Odd or Even


The Excel function IsOdd() and IsEven() both return a Boolean “True” if the contents are Odd or “Even” respectively. This negates an external truth check as described above.


This is easily shown by adding a formula to the Checker area


=Row()+Column()



Excel 2003: The above formula won’t work in Excel 2003.


Try this instead =Mod(Row()+Column(),2)=1


If the alternate shading is required a switch to


=ISEVEN(ROW()+COLUMN())


Does the trick.



Excel 2003: The above formula won’t work in Excel 2003.


Try this instead =Mod(Row()+Column(),2)=0


http://chandoo.org/wp/2009/03/13/excel-conditional-formatting-basics/


and


http://chandoo.org/wp/2008/03/13/want-to-be-an-excel-conditional-formatting-rock-star-read-this/


and


http://chandoo.org/wp/2008/10/14/more-than-3-conditional-formats-in-excel/


You can download a copy of the above file and follow along, Download Here.


You can learn more about how to pull Excel Formulas apart in the following posts


Formula Forensics 001 – Tarun’s Problem


Formula Forensics 002 – Joyce’s Question


Formula Forensics 003 – Lukes Reward


Formula Forensics 004 – Freds Problem


If you have a neat formula that you would like to share and explain, try putting pen to paper and draft up a Post as Luke did in Formula Forensics 003. or this post.


If you have a formula that you don’t understand and would like explained but don’t want to write a post also send it in to Chandoo or Hui.


Spread some love,
It makes you awesome!


Posts & Navigation


Tags: Check-Board, column(), if(), iseven(), IsOdd(), Learn Excel, Microsoft Excel Conditional Formatting, Microsoft Excel Formulas, MOD(), row(), Zebra Stripes



RSS feed for comments on this post. TrackBack URI



View the original article here

Friday, December 23, 2011

Formula Forensics. No 007 – Sumproduct

One of the most asked questions within the posts and Forums at Chandoo.org is “How Does Sumproduct work ?”.

Rahul recently asked for an example in Excels Sumproduct Formula post;  Comment No. 55.

So today in Formula Forensics we will take a look at just that with a few worked examples.

Excels help defines Sumproduct as:



So what are these arrays referring to:

An array in Excel can be :

A manual Array:     {10;20;30}

A Range:              A1:A3

A Named Range: MyRange1

Where MyRange1 is defined as a defined range in the Name Manager.

A Named Formula: MyRange2

Where MyRange2 is defined as a Formula returning a range in the Name Manager.

Lets look at each

You can follow along in the Example file on Sheet1

An Array

In C2 type: =SUMPRODUCT({10;20;30})

Excel will display 60, which is the Sum of the array elements =10+20+30

A Range

C7:          =Sumproduct(C4:C6)

Excel displays 60, which is the Sum of the cells from the range C4:C6 =10+20+30

A Named Range

In the Name Manager or Name Box define a Named Range

MyRange1:         =Sheet1!$C$4:$C$6

Then in C10 type:

C10: =Sumproduct(MyRange1)

Excel displays 60, which is the Sum of the range elements =10+20+30

A Named Formula

In the Name Manager define a Named Formula

MyRange2          =OFFSET(Sheet1!$C$3,1,0,3,1)

Then in C12 type:

C12:       =Sumproduct(MyRange2)

Excel displays 60, which is the Sum of the range elements from cells C4:C6 =10+20+30

You may be asking why use Sumproduct when we can use a simple Sum to add up 3 numbers?

The answer is to show you what Sumproduct is doing, it is Adding up each Array element.

Remember back at the start where we saw the Definition of Sumproduct,

SUMPRODUCT(array1, [array2], [array3], …)

Only Array 1 is required, Array 2, Array 3 etc are optional, that’s what the square brackets [ ] mean.

Goto Sheet 2 in the Example file:

We will look at a simple example using two arrays



The data consists of Sales data.

Often we want to know what the total sales are

We do this by  adding a Sales column



Which multiplies the Qty and Price columns

And then Sum (Add) up this new column



Returning our Total Sales of 15,000

Now we can manually check the above as the numbers are simple eg: 100*20 = 2,000 etc

And we can sum up the Sales and see that we in fact had total sales of 15,000

Well this is exactly what Sumproduct is made to do:

In a Blank cell enter: =SUMPRODUCT(D4:D8,E4:E8)



Excel will return 15,000.

So what is Sumproduct doing?

Lets look inside and see what’s going on

In the Example File, Sheet2, H1 there is a copy of the data laid out as below



Note that our formula =SUMPRODUCT(D4:D8,E4:E8)

Has two Arrays

Array 1: D4:D8

Array 2: E4:E8

Note that each corresponding Array Element is multiplied together

100 x 20

20 x 200 etc

These are the products of the two Arrays

Finally the Products are Added together and the correct answer 15,000 is returned.

So Sumproduct is the Sum of the Products of the Arrays

Of course we can extend that to a large number of Arrays, columns in this case, if we wish.

In the above two examples we saw that Sumproduct can Sum a single Array and can Sum the Product of two or more Arrays.

We can use that to our advantage and build logic into the arrays, allowing us to optionally include some array elements and leave out others.

Sumproduct will always add up the product of all Arrays.

So by including an Array where the elements within the Array that we don’t want to Sum are Zero and the Elements within the array that we do want to Sum are 1 we can control what is included in the final Summation.

Goto our Example File on Sheet3

Lets say we only want to include the Sales from our Northern Region

One way to do this is to purely delete the other entries



But what if we could do that without altering our worksheet or there are thousands of rows of data?

This is where Sumproduct comes into its own.

What we need to do is add some logic to our equation, effectively doing:



Lets try it with Sumproduct

In Cell F12: type =SUMPRODUCT(D4:D8,E4:E8,{FALSE;TRUE;FALSE;FALSE;TRUE})

Excel displays a -

Excel doesn’t know what to do with the True/False and so converts them to 0

We can force excel to evaluate these as numbers by adding a simple “1*”

In F14: Type =SUMPRODUCT(D4:D8,E4:E8,1*{FALSE;TRUE;FALSE;FALSE;TRUE})

Excel now displays 5,000 the total sales from the North

To see what has happened in F16 type: 1*{FALSE;TRUE;FALSE;FALSE;TRUE}, but don’t press Enter press F9 instead.

Excel displays ={0;1;0;0;1}

The use of the 1* has converted each of the Array elements from a True/False to a 1,0 respectively.

So our 3 arrays are now:



Now adding an Array of 1*{FALSE;TRUE;FALSE;FALSE;TRUE} every time we wanted to add some numbers isn’t a practical solution.

Excel has the ability to work construct an Array on our behalf!

In E18: enter  =SUMPRODUCT(D4:D8,E4:E8,1*(C4:C8=”North”))

Excel will display 5,000

So 1*(C4:C8=”North”) is exactly equal to our previous array 1*{FALSE;TRUE;FALSE;FALSE;TRUE}

1*(C4:C8=”North”) = 1*{FALSE;TRUE;FALSE;FALSE;TRUE}

At the heart of this is that Excel is evaluating each cell in the Range: C4:C8 against our required logic =”North” and setting up an Array for us internally.

The power of Sumproduct is therefore in that we can now simplify and extend

In cell E20 type: North

In cell F20 type: =SUMPRODUCT(D4:D8,E4:E8,1*(C4:C8=E20))

Excel will display 5,000

This simple addition allows us to vary the Summation based on the value in E20

We don’t need to multiply our logic array by 1, we can actually use any number or another Array.

In cell F22 type: =SUMPRODUCT(D4:D8,(E4:E8)*(C4:C8=E20))

This works as (C4:C8=E20) is returning an Array of True/False which get converted to an array of 1/0’s when subject to any maths.

The Math in this case is the multiplication by the 2nd Array (E4:E8)*(C4:C8=E20)

In Cell F24 type: =SUMPRODUCT(Qty, Price *(Region=SalesRegion))

Excel will display 5,000

But notice that by using Named Ranges/Formula how simple the logic of the equation has now become.

In Comment No. 55: Rahul asked, “Can you give an example work sheet of above example”

Sheet 4 in the Example File is the answer.



In Cell C23: type: =SUMPRODUCT(- -(A2:A21=”Luke Skywalker”),- -(B2:B21=”West”),C2:C21)

Excel will display 141, which is the sum of the Sales made by Luke Skywalker in the West Region.

However using what was learned above, this is better simplified to:

C26: =SUMPRODUCT((Name=SalesMan)*(Region=SalesRegion)*Sales)

In the formula above Chandoo has used what is known as a Double Unary, which is 2 – signs next to each other (I have inserted a space above to make it more legible).

Two – signs are the same as saying

- -(A2:A21=”Luke Skywalker”) = -1 x -1 x (A2:A21=”Luke Skywalker”)

-1 x -1 is 1

Technically this is the most efficient way for Excel to perform any maths on the Array

- -(A2:A21=”Luke Skywalker”)

So that the Array of true/Falses made by (A2:A21=”Luke Skywalker”) is converted to an Array of 1/0’s for use in Sumproduct.

At the slight expense of speed but for improved readability and understandability by others I prefer the use of 1* instead of - – and you will mostly see that convention in my posts.

Chandoo:            - -(A2:A21=”Luke Skywalker”)

Hui:                       1*(A2:A21=”Luke Skywalker”)

In fact any maths performed on the array will convert its contents to an array of 1/0’s, so long as the maths doesn’t change the Arrays values

For a real good discussion on this topic have a look at the post The Venerable SUMPRODUCT at ExcelHero.com

http://chandoo.org/wp/2009/11/10/excel-sumproduct-formula/

http://chandoo.org/wp/2011/05/26/advanced-sumproduct-queries/

http://chandoo.org/wp/tag/sumproduct/

http://www.excelhero.com/blog/2010/01/the-venerable-sumproduct.html

You can download a copy of the above file and follow along, Download Here.

You can learn more about how to pull Excel Formulas apart and what makes them tick in the following post:

Formula Forensic Series:

I am running out of ideas for Formula Forensics and so I need your help.

If you have a neat formula that you would like to share and explain, try putting pen to paper and draft up a Post as Luke did in Formula Forensics 003. or like above.

If you have a formula that you would like explained but don’t want to write a post also send it in to Chandoo or Hui.

This will be the last Formula Forensics Post for 2011, but rest assured that we will be returning in early 2012.

I’d like to take the opportunity to thank Chandoo for allowing me the space and freedom to post pretty much what ever I’ve wanted at Chandoo.org. I hope you have enjoyed my contributions to the Chandoo.org community over the past year.

On behalf of Eva and myself I’d like to wish you all a very Merry Xmas and a Happy and Safe New Year ahead


RSS feed for comments on this post. TrackBack URI


View the original article here

Saturday, April 9, 2011

Ends one week to create expense reports date expression method in Microsoft Excel is?


Let's say you are putting together use to your employees for all expense report sheet. Allow one week to enter end date is calculated automatically for the rest of the day of the week spreadsheet. We use two main formulas are as follows:

= IF (B1 "", IF (7 WEEKDAY (B1), B1+7-WEEKDAY (B1), B1), "")

= IF ($ b $ 2 "", $ b $ 2-6, "")

In cell B1 in the date blank if you do not () says at first (""), then go to the next part of the formula, and otherwise leave blank. Returns the number that identifies the date formula = weekday() 1 to 7 of the day. In this example, to February 12, 2010 end date as week selected. = weekday (B1) 6. So, add, and then if you don't get value equal to 7, with B1 Sunday B1, 6, 12, 19 for B1, 5 x 6. We end at 13. (Summary: 12 + 7 = 19 19 - 6 = 13. )? The date is February 13, 2010.

Each day of the following formula. Sunday's formula is: IF ($ b $ 2 "", $ b $ 2-6, "") to =. If B2 is insignificant and 6 draws, otherwise, blank. We give correct date Sunday, 07 February 2010 13-6 example 7 =. Monday formula: we give a 13-7 = IF ($ b $ 2 "", $ b $ 2-5, "") to 8 February till Saturday) = 8. One simple way is there to improve the expense report.

I just put it as a template, and also would work, but how many people tried, and how, understanding job time consuming to do you care to explain? Feel you learn a lot and trying to build yourself these spreadsheets to achieve much. Do you have any questions or comments please feel free to if they tell me.








Thanks for reading!
http://excelspreadsheetshelp.blogspot.com/