[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Excel Formula Question

Posted on 2011-02-23
6
Medium Priority
?
243 Views
Last Modified: 2013-11-05
I've been trying to figure this out on my own for a week. Formulas just aren't my strong suit.

I have a column of data in A. From A1 to A200 let's say. I want a formula that will test each value in column A and assign it a different value in B. For example, if A1 is between 1 and 11, I would like a value in B1 of -1 and I want to carry this on all the way down the line.

The range values I am look at are:
1-11: -2
12-23: -1
24-35: 0
36-47: 1
48-59: 2

Arcane Excel Wizards, I call upon your dark powers to aid me....
0
Comment
Question by:taiell0
6 Comments
 
LVL 11

Expert Comment

by:Runrigger
ID: 34960494
TRY THIS

=IF(A1<12,-2,IF(A1<24,-1,IF(A1<36,0,IF(A1<48,1,2))))
0
 
LVL 33

Accepted Solution

by:
jppinto earned 2000 total points
ID: 34960517
Put this in cell B1 and copy down:

=IF(AND(A1>=1,A1<=11),-2,IF(AND(A1>=12,A1<=23),-1,IF(AND(A1>=24,A1<=35),0,IF(AND(A1>=36,A1<=47),1,IF(AND(A1>=48,A1<=59),2,"")))))

jppinto
0
 
LVL 33

Expert Comment

by:jppinto
ID: 34960525
Example attached...
Book1.xlsx
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:Runrigger
ID: 34960543
jppinto, I don't think that you really need something to test all conditions, the requirement enters a different result for increasing values, so you only need to test the upper range of each in ascending order (or lower range or each in a descending order).

My only omission was to enter a catch all for value greater than 48 of "2" which you have done;

=IF(A1<12,-2,IF(A1<24,-1,IF(A1<36,0,IF(A1<48,1,IF(A1<60,2,"")))))

would give the same result.
0
 

Author Closing Comment

by:taiell0
ID: 34960547
That was bad ass. Thank you!
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 34960551
You could use LOOKUP like this in B1 copied down, which can be generalised for any ranges and or values to be returned......

=LOOKUP(A1,{1,12,24,36,48;-2,-1,0,1,2)

....or for your specific values in your example, becauise there's a consistent pattern

=INT(A1/12)-2
  regards, barry
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question