Solved

Excel Formula Question

Posted on 2011-02-23
6
234 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 500 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now