complicated if statement :: MrExcel Message Board


 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

complicated if statement
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

Curious
Board Regular


Joined: 22 Aug 2003
Posts: 32

Flag: Blank

Status: Offline

 Reply with quote  

complicated if statement

I have thousands of row in a sheet that look like the following:


Column A Column B Column C

CG000045 $2,756.00 1
CG000045 $225.00 2
CG000062 $4,603.00 1
CG000062 $188.00 2
CG000062 $731.00 2
CG000057 $3,419.00 1
CG000057 $73.00 2
CG000069 $2,660.00 1
CG000069 $1,496.00 2
CG000069 $41.00 2
CG000069 $149.00 2


What do I need to do to get the following result:

CG000045 $2,756.00 1
CG000045 $225.00 2
CG000062 $4,603.00 1
CG000062 $919 2
CG000057 $3,419.00 1
CG000057 $73.00 2
CG000069 $2,660.00 1
CG000069 $1786 2

In other words if column C is "2" and column A is the same add the value in column C together such thatI will only have one row with column C is 1 and one row with column C is 2 with column A being the same number.

I hope I have made sense. and some one can help me.

Thank you in advance. icon_bow.gif icon_bow.gif icon_bow.gif icon_bow.gif

Post Tue Sep 16, 2003 12:18 pm 
 View user's profile Send private message

Andrew Poulsom
MrExcel MVP


Joined: 22 Jul 2002
Posts: 8266

Flag: Uk

Status: Offline

 Reply with quote  

Re: complicated if statement

Have you tried a Pivot Table?

Post Tue Sep 16, 2003 12:27 pm 
 View user's profile Send private message

jimboy
Board Master
Board  Master


Joined: 12 Apr 2002
Posts: 1741

Flag: England

Status: Offline

 Reply with quote  

Re: complicated if statement

A pivot table can do this.

Put column A & B in Row and Sum of Col. C in Data.

Post Tue Sep 16, 2003 12:30 pm 
 View user's profile Send private message

eliW
Board Master


Joined: 03 Mar 2002
Posts: 903

Flag: Blank

Status: Offline

 Reply with quote  

Re: complicated if statement

quote:
Originally posted by Curious:
I have thousands of row in a sheet that look like the following:

.........
In other words if column C is "2" and column A is the same add the value in column C together such thatI will only have one row with column C is 1 and one row with column C is 2 with column A being the same number.
I hope I have made sense. and some one can help me.

Thank you in advance. icon_bow.gif icon_bow.gif icon_bow.gif icon_bow.gif


Hi

Your question is not clear enough, I think that in last sentences there is some typo error.

Any way I've noticed that records with C=1 are unique in your example. Is this always so?

If the answer is no then would you sum them also?

Your question is a classic issue for consolidation or pivot tables,

Eli

Post Tue Sep 16, 2003 12:31 pm 
 View user's profile Send private message Send e-mail

Brian from Maui
Board Master
Board Master


Joined: 17 Feb 2002
Posts: 2506

Flag: Blank

Status: Offline

 Reply with quote  

Re: complicated if statement

Pivot Table,

Microsoft Excel - Book1___Running: xl2002 XP : OS = Windows XP
File Edit View Insert Options Tools Data Window Help About
=

A
B
C
D
3
Sum of CostNumber  
4
Product12Grand Total
5
CG00004527562252981
6
CG0000573419733492
7
CG00006246039195522
8
CG000069266016864346
9
Grand Total13438290316341
Sheet2 

[HtmlMaker light Ver1.10] To see the formula in the cells just click on the cells hyperlink or click the Name box
PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.

Post Tue Sep 16, 2003 12:37 pm 
 View user's profile Send private message

x-amount
Board Master


Joined: 16 May 2003
Posts: 100


Status: Offline

 Reply with quote  

Re: complicated if statement

You can probably use a pivot table.

But, if you are like me, however, I hate PT's.

This is quite a longwinded solution, I'm afraid
Insert a column to the left of a and insert the formula
=b2&"_"&d2

Fill this down for the length of the data.

Insert a column between to the left of A, and insert the formula

=countif(b2:$B$2,2) in cell a2

and fill down.

In column f, insert the formula

=sumif(b:b,b2,d:d)

and fill down, (and replace with values)


Copy column f and paste it OVER column d as values

Autofilter column a on all cells which aren't 1

Delete those rows (which dont have 1 as there value) , take off the autofilter and delete columns a and b

et voila. That should do it

Thats how I'd do it, anyway, by the looks of things, theres probably a much quicker way!

Post Tue Sep 16, 2003 12:37 pm 
 View user's profile Send private message

Curious
Board Regular


Joined: 22 Aug 2003
Posts: 32

Flag: Blank

Status: Offline

 Reply with quote  

Re: complicated if statement

Thanks for the info. I tried it and I got the following:
1-CG000726 -1429 1
261 1
10189 1
1-CG000726 Total 3
1-CG000727 3997 1
1-CG000727 Total 1
1-CG000730 72 1
3997 1
1-CG000730 Total 2
This is not what I am looking for. I have tried to download the colo HTML maker so I can display my sheet but I must be doing something wrong as I get the zip file but I am not sure what to do next. If I could get instructions how to download and use the HTML maker I would appriciate it and maybe then I can show you what I am really asking.

Thanks

Post Tue Sep 16, 2003 12:44 pm 
 View user's profile Send private message

Curious
Board Regular


Joined: 22 Aug 2003
Posts: 32

Flag: Blank

Status: Offline

 Reply with quote  

Re: complicated if statement

The following is what I am looking for:
















































































































































Before    
     
Policy Premium Audit
CG000001 $44,392.00 1
CG000001 $3,249.00 2
CG000063 $3,067.00 1
CG000063 $156.00 2
CG000065 $4,328.00 1
CG000076 $3,125.00 1
CG000015 $20,969.00 1
CG000015 $1,475.00 2
CG000056 $2,406.00 1
CG000056 $866.00 2
CG000056 $115.00 2
     
After    
Policy Premium Audit
CG000001 $44,392.00 1
CG000001 $3,249.00 2
CG000063 $3,067.00 1
CG000063 $156.00 2
CG000065 $4,328.00 1
CG000076 $3,125.00 1
CG000015 $20,969.00 1
CG000015 $1,475.00 2
CG000056 $2,406.00 1
CG000056 $981.00 2
     

Post Tue Sep 16, 2003 4:25 pm 
 View user's profile Send private message

Juan Pablo González
MrExcel MVP


Joined: 09 Feb 2002
Posts: 8580
Location: Marion, IL
Flag: Colombia

Status: Offline

 Reply with quote  

Re: complicated if statement

Using the Excel ODBC and an SQL statement like this:

SELECT `Sheet1$`.Policy, Sum(`Sheet1$`.Premium) AS 'Sum of Premium', `Sheet1$`.Audit
FROM `C:\Book3`.`Sheet1$` `Sheet1$`
GROUP BY `Sheet1$`.Policy, `Sheet1$`.Audit

its possible to do what you want... where 'C:\Book3' is the name and location of the file, and Sheet1 the sheet where the data is located.
_________________
Regards,

Juan Pablo González
MrExcel.com Consulting

Read the Articles List and check out our Recommended links and Add-Ins

Post Tue Sep 16, 2003 4:43 pm 
 View user's profile Send private message Visit poster's website
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.