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 Mar 13th, 2002, 06:33 AM   #1
Chris Davison
MrExcel MVP
 
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
Default

Morning all,

{"Name","Code","Amount";"John",1,5;"Paul",1,10;"George",1,15;"Ringo",1,20;"Bob",2,25;"John",2,30;"John",1,35;"John",1,40;"John",3,45}

I'm filtering column A so it only shows "John". We're all familiar with the =SUBTOTAL function that will sum only visible rows, but I'd like to subtotal only if the code is 1.

My ultimate goal is to have totals for each code which change as I filter by each name in column A.

(If it's not possible, I'll revert back to a pivot table)

so basically, can I use =SUBTOTAL with a single criteria ? (like =SUMIF does)

many thanks
Chris


edit - answer in the above example should be 80



[ This Message was edited by: Chris Davison on 2002-03-13 05:34 ]
Chris Davison is offline   Reply With Quote
Old Mar 13th, 2002, 06:43 AM   #2
Barrie Davidson
MrExcel MVP
 
Barrie Davidson's Avatar
 
Join Date: Feb 2002
Location: Winnipeg
Posts: 2,330
Default

Quote:
On 2002-03-13 05:33, Chris Davison wrote:
Morning all,

{"Name","Code","Amount";"John",1,5;"Paul",1,10;"George",1,15;"Ringo",1,20;"Bob",2,25;"John",2,30;"John",1,35;"John",1,40;"John",3,45}

I'm filtering column A so it only shows "John". We're all familiar with the =SUBTOTAL function that will sum only visible rows, but I'd like to subtotal only if the code is 1.

My ultimate goal is to have totals for each code which change as I filter by each name in column A.

(If it's not possible, I'll revert back to a pivot table)

so basically, can I use =SUBTOTAL with a single criteria ? (like =SUMIF does)

many thanks
Chris


edit - answer in the above example should be 80



[ This Message was edited by: Chris Davison on 2002-03-13 05:34 ]
Chris, why not filter on the Code as well?

Regards,
__________________
Barrie Davidson

"You're only given a little spark of madness. You mustn't lose it." - Robin Williams
Barrie Davidson is offline   Reply With Quote
Old Mar 13th, 2002, 06:55 AM   #3
Chris Davison
MrExcel MVP
 
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
Default

thanks Barrie

Unfortunately, I will be showing all the other data, it's just the names I'll be filtering
Chris Davison is offline   Reply With Quote
Old Mar 13th, 2002, 07:01 AM   #4
Barrie Davidson
MrExcel MVP
 
Barrie Davidson's Avatar
 
Join Date: Feb 2002
Location: Winnipeg
Posts: 2,330
Default

Quote:
On 2002-03-13 05:55, Chris Davison wrote:
thanks Barrie

Unfortunately, I will be showing all the other data, it's just the names I'll be filtering
Sorry Chris, as far as I know (with my limited knowledge, and I'm willing to bet Aladin or Mark W will be able to come up with something!) you can't do this so you'll have to resort back to your pivot table.

Regards,
__________________
Barrie Davidson

"You're only given a little spark of madness. You mustn't lose it." - Robin Williams
Barrie Davidson is offline   Reply With Quote
Old Mar 13th, 2002, 07:11 AM   #5
Chris Davison
MrExcel MVP
 
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
Default

Hey, no worries !

(Previously, I had been doing seperate tables of names in seperate worksheets, pasted from my accounting system - so I figured rather than doing 30 seperate pastes, I could do a single paste and then just use criteria and filter to cut down the 2 days it takes to just maybe a few hours whilst also, for presentation purposes, I didn't want any ugly pivot tables)

It could just be I started off in the wrong direction designwise so may have to go a different way

thanks though, much appreciated
Chris
Chris Davison is offline   Reply With Quote
Old Mar 13th, 2002, 11:03 AM   #6
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Quote:
On 2002-03-13 05:33, Chris Davison wrote:
Morning all,

{"Name","Code","Amount";"John",1,5;"Paul",1,10;"George",1,15;"Ringo",1,20;"Bob",2,25;"John",2,30;"John",1,35;"John",1,40;"John",3,45}

I'm filtering column A so it only shows "John". We're all familiar with the =SUBTOTAL function that will sum only visible rows, but I'd like to subtotal only if the code is 1.

My ultimate goal is to have totals for each code which change as I filter by each name in column A.

(If it's not possible, I'll revert back to a pivot table)

so basically, can I use =SUBTOTAL with a single criteria ? (like =SUMIF does)

many thanks
Chris
[img]/board/images/smiles/icon_smile.gif[/img]

edit - answer in the above example should be 80

[ This Message was edited by: Chris Davison on 2002-03-13 05:34 ]
Chris,

Beside PivotTables, you have also formula-based approaches to the task you've set up for us. I don't believe SUBTOTAL can be of any help in conditional summing.

I'll skip SUMPRODUCT/array-formulas.

I'll assume that A1:C10 houses the sample data you provided.

Select A1:C10 and name it Dbase (via the Name Box).

Activate A2.
Activate Data|Filter|Advanced Filter.
Check 'Copy to another location'.
Set the 'Input range' to $A$1:$A$10.
Set 'Copy to' to $J$1.
Check 'Unique records only'.
Click OK.

Activate B2.
Activate Data|Filter|Advanced Filter.
Check 'Copy to another location'.
Set the 'Input range' to $B$1:$B$10.
Set 'Copy to' to $K$1.
Check 'Unique records only'.
Click OK.

Select all of the cells filtered to J1 from J2 on.
Name it Names.
Select all of the cells filtered to K1 from K2 on.
Name it Codes.

I'd suggest moving Names and Codes to a separate sheet you could call Admin.

In E1:F1 enter:

{"Name","Code"}

Activate E2.
Activate Data|Validation.
Choose 'List' for Allow.
Enter as source:

=Names

Activate F2.
Activate Data|Validation.
Choose 'List' for Allow.
Enter as source:

=Codes

Select E1:F2 and name it Conditions (via the Name Box).

In G2 enter:

=DSUM(Dbase,3,Conditions)

Experiment.

Selecting John in E2 and 1 in F2, I get 80 in G2.

Aladin

Aladin Akyurek is offline   Reply With Quote
Old Mar 13th, 2002, 02:58 PM   #7
Chris Davison
MrExcel MVP
 
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
Default

thanks for your time on this Aladin, I think it outvotes my workaround.... I just popped some columns to the right which said "if it's code 1 then put in the value" "if it's code 2 then put in the value" etc etc then had subtotals at the top of each column, which were referenced back, which worked but left me with zillions of formulae and a lag time when I filtered.

With a maximum of a dozen names and 30 codes, (both static), I now only need 300ish DSUM formula, rather than 1000 rows of my 30-column workaround

can't wait to use this Thursday morning !

cheers mate
Chris


[ This Message was edited by: Chris Davison on 2002-03-13 13:59 ]
Chris Davison 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 09:39 AM.


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