MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Feb 24th, 2002, 10:46 PM   #1
Bob Matthews
New Member
 
Join Date: Feb 2002
Location: Australia
Posts: 3
Default

I have a spreadsheet with lots of daily transactions and a balance after each transaction. There could be more than one transaction per day while some days may have none. I am trying to work out a formula which identifies the first and last transaction for each month so I end up with a monthly opening and closing balance for each month. A sample of the data is below:

Date Type Qty Balance
01-Feb-99 Sales -2 103
01-Feb-99 Sales -1 102
08-Feb-99 Sales -2 100
26-Feb-99 Sales -3 97
26-Feb-99 Sales -6 91
01-Mar-99 Sales -1 90
01-Mar-99 Sales -2 88
31-Mar-99 Sales -4 84
31-Mar-99 Sales -2 82

Hope someone can help.

Thanks
Bob
Bob Matthews is offline   Reply With Quote
Old Feb 25th, 2002, 01:41 AM   #2
Derek
Board Regular
 
Join Date: Feb 2002
Location: Perth Australia
Posts: 1,567
Default

Bob
I am sure there is an easier way to achieve what you are after by a pivot table, but since they aren't my strong point, here's an attempt at a formula solution

Assuming the following
A:A = Your Dates
B:B = Type
C:C = Qty
D:D = Balance

Put this formula in E6
=IF(MONTH(A6)>MONTH(A5),A6,IF(MONTH(A6)
Provided your dates are continuous without a break, you can scroll this formula up/down and it will show only the first and last day of the month (ie it returns the date in A6 if it is the first or last day of the month).
You can use this formula again in column F to return D6 (instead of A6) to get the balance for that date.
Since this formula looks at the date above and below it will only work if your dates extend far enough back and forward for it to see a change in the month.
Hope this helps
Derek

[ This Message was edited by: Derek on 2002-02-25 00:48 ]

[ This Message was edited by: Derek on 2002-02-25 00:50 ]
Derek is offline   Reply With Quote
Old Feb 25th, 2002, 01:53 AM   #3
Derek
Board Regular
 
Join Date: Feb 2002
Location: Perth Australia
Posts: 1,567
Default

=IF(MONTH(A6)>MONTH(A5),A6,IF(MONTH(A6)

For some reason the post is truncating my formula, If this doesn't print out properly either,please add Derek

[ This Message was edited by: Derek on 2002-02-25 00:54 ]
Derek is offline   Reply With Quote
Old Feb 25th, 2002, 01:57 AM   #4
Derek
Board Regular
 
Join Date: Feb 2002
Location: Perth Australia
Posts: 1,567
Default


This is so frustrating (this is the end of the formula). If it doesn't accept it this time, I give up
Derek

[ This Message was edited by: Derek on 2002-02-25 00:59 ]
Derek is offline   Reply With Quote
Old Feb 25th, 2002, 01:58 AM   #5
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

If your monthly balances are always lowest at the end of the month, then you could do the following. Create a pivot table by selecting you data and choosing Data-Pivot Table Report. Click Next on the first two screens. On Step 3 of the Pivot Table Wizard, drag the 'Date' entry into the 'ROW' part of the table. Drag Balance into the middle of the Table and double click on it and select Max from the list. Do the same, but select Min this time. Click Finish. On the pivot table that now appears, right-click on the Date heading and choose Group, then group into months. Your final table should look like the one below (get rid of the sub totals if you don't want them). Hope this is what you were after.


Feb Max of Balance 103
Min of Balance 91
Mar Max of Balance 90
Min of Balance 82
Total Max of Balance 103
Total Min of Balance 82
Mudface is offline   Reply With Quote
Old Feb 25th, 2002, 02:18 AM   #6
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,314
Default

Quote:
On 2002-02-24 21:46, Bob Matthews wrote:
I have a spreadsheet with lots of daily transactions and a balance after each transaction. There could be more than one transaction per day while some days may have none. I am trying to work out a formula which identifies the first and last transaction for each month so I end up with a monthly opening and closing balance for each month. A sample of the data is below:

Date Type Qty Balance
01-Feb-99 Sales -2 103
01-Feb-99 Sales -1 102
08-Feb-99 Sales -2 100
26-Feb-99 Sales -3 97
26-Feb-99 Sales -6 91
01-Mar-99 Sales -1 90
01-Mar-99 Sales -2 88
31-Mar-99 Sales -4 84
31-Mar-99 Sales -2 82
Bob,

What follows might be a bit heavy (if not convoluted).

I'll assume that A1:D12 houses the sample data including labels. By the way, I added 2 more records to the sample:

{"Date","Type","Qty","Balance";
36192,"Sales",-2,103;
36192,"Sales",-1,102;
36199,"Sales",-2,100;
36217,"Sales",-3,97;
36217,"Sales",-6,91;
36220,"Sales",-1,90;
36220,"Sales",-2,88;
36250,"Sales",-4,84;
36250,"Sales",-2,82;
36253,"Sales",-7,78;
36278,"Sales",-8,67}

In F1 enter:

=MATCH(9.99999999999999E+307,A:A)

In F2:H2 enter:

{1999,
"First Transaction",
"Last Transaction"}

In F3:F14 enter:

{"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"}

Note 1. I've chosen 3-letter month names. A different choice requires adapting the formulas that follow.

In G3 array-enter:

=INDEX(D:D,MATCH(MIN(IF(TEXT(OFFSET($A$2,0,0,$F$1,1),"mmm")=$F3,(OFFSET($A$2,0,0,$F$1,1)))),OFFSET($A$2,0,0,$F$1,1),0)+1)

In H3 array-enter:

=INDEX(D:D,MATCH(MAX(IF(TEXT(OFFSET($A$2,0,0,$F$1,1),"mmm")=$F3,(OFFSET($A$2,0,0,$F$1,1)))),OFFSET($A$2,0,0,$F$1,1),0)+COUNTIF(A:A,MAX(IF(TEXT(OFFSET($A$2,0,0,$F$1,1),"mmm")=$F3,(OFFSET($A$2,0,0,$F$1,1))))))

Note 2. In order to array-enter a formula, you need to hit control+shift+enter at the same time, not just enter.

Select G3:H3 and copy down till the Dec row.

This is what you get to see in F1:H6, showing only Jan to Apr results:

{12,"","";
1999,"First Transaction","Last Transaction";
"Jan",#N/A,#N/A;
"Feb",103,91;
"Mar",90,82;
"Apr",78,67}

Note that we have #N/A for Jan, due to the absence of data regarding that month. If you'd like not to see #N/A's, you can apply Cond Format to the result range to whiten them.

Aladin
Aladin Akyurek is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 06:32 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes