Wikiposts
Search
Computer/Internet Issues & Troubleshooting Anyone with questions about the terribly complex world of computers or the internet should try here. NOT FOR REPORTING ISSUES WITH PPRuNe FORUMS! Please use the subforum "PPRuNe Problems or Queries."

IF Statement in Excel

Thread Tools
 
Search this Thread
 
Old 24th Jan 2007, 19:05
  #1 (permalink)  
Thread Starter
 
Join Date: Jun 2006
Location: BRISTOL!
Age: 39
Posts: 526
Likes: 0
Received 0 Likes on 0 Posts
IF Statement in Excel

Hey All...

I need and IF Statement that can put a "1" in the colum after the week sales value if it is the best selling CD that week, or if its not put a 0?

And does anyone know how i can print the album name of the best selling single that week in a table? like week one = , etc?

Cheers all

PS: HERE IS THE ROUGH TABLE

ARTIST | WEEK ONE | FAV | WEEK 2 | FAV
U2 | 200 | WANT 1 HERE IF IT IS
UB40 | 100 | ITS NOT THE FAVORITE SO A 0
planecrazy.eu is offline  
Old 25th Jan 2007, 03:34
  #2 (permalink)  
 
Join Date: Jan 2007
Location: Mostly in my own imagination
Posts: 481
Received 361 Likes on 168 Posts
..| ...A.. | ...B.. | .C. | ...D.. | .E
--|---------------------------------------
1 | ARTIST | WEEK 1 | FAV | WEEK 2 | FAV
2 | U2.... | 200... | 1.. |....... |
3 | UB40.. | 100... | 0.. |....... |
4 | ABBA.. | 150... | 0.. |....... |



Put the following formula into C2 and drag it down to the cells below (C3:C4 in this case)

=IF(B2 = MAX(B$2:B$4),"1","0")


If you want to get clever, then set up a range to replace the B$2:B$4 part.

If you want to get really clever, you can use the xldown function to define the range, but I forget the syntax for that one.






btw, I tried it and it works
Sue Vêtements is offline  
Old 25th Jan 2007, 12:32
  #3 (permalink)  
 
Join Date: Sep 2002
Location: UK
Posts: 34
Likes: 0
Received 0 Likes on 0 Posts
Originally Posted by Sue Vêtements
If you want to get clever, then set up a range to replace the B$2:B$4 part.
If you want to get really clever, you can use the xldown function to define the range, but I forget the syntax for that one.
To define a dynamic range for column B that will expand or contract depending on the data, define a Name (e.g. week1) that refers to:

=OFFSET(Sheet1!$B$2,0,0,COUNTA(Sheet1!$B:$B)-1,1)

This defines a range that starts at cell B2, with a height as the number of populated cells in column B (assuming no gaps and minus 1 to allow for the column heading) and a width of 1.

Then use this named range in your formula:

=IF(B2 = MAX(WEEK1),"1","0")

xlDown is a VBA constant that is used to specify the direction for the END property of a range, e.g.

Range("$B$B").End(xldown).Row

This could be used (as part of a user-defined function) instead of COUNTA in the above formula.

Vindaloo
vindaloo is offline  
Old 26th Jan 2007, 16:43
  #4 (permalink)  
Thread Starter
 
Join Date: Jun 2006
Location: BRISTOL!
Age: 39
Posts: 526
Likes: 0
Received 0 Likes on 0 Posts
Thanks for the feedback "ANSWER" =)

Works a treat, thanks
planecrazy.eu is offline  
Old 31st Jan 2007, 09:27
  #5 (permalink)  
 
Join Date: Jan 2003
Location: Southampton
Posts: 859
Received 60 Likes on 25 Posts
If you get stuck again try this lot:

http://www.mrexcel.com/board2/

if they don't know the answer nobody will.
Saintsman is offline  

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 Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Contact Us - Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service

Copyright © 2024 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.