Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBA Excel Categorize data Upper and lower bound

Posted on 2009-05-12
3
Medium Priority
?
1,030 Views
Last Modified: 2013-11-25
Hi,

I have the following problem: What should I do if I am looking at data and would like to categorize this data into a basket. Lets say I hava a bond with a maturity of 10 years and the options are if maturity > 5 =1 and <5=2 . This Bond would go into category 1 as it is greater than 5. Unfortunately I have more than 2 bounds - these can be seen in the attached excel sheet. The data can be found on the sheet Info, the criteria on sheet criteria and the result should bedisplayed on sheet calculation. Are you able to help?

Thanks

kbrasco
categorize.xls
0
Comment
Question by:kbrasco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 total points
ID: 24366248
Like this?
Regards,
Rory

categorize.xls
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 24366273
VLOOKUP is a handy function that allows you to return a value from a "lookup" table based on an "index"
value in the table's left-most column.

The URL below links to an excellent start-up tutorial for VLOOKUP:

http://www.theofficeexperts.com/excel.htm#TheDreadedVlookup

Keep in mind the following:
1) If you omit the optional 4th argument, or set it to TRUE, then VLOOKUP looks for the greatest value in
the lookup column that is less than or equal to the value being sought.  Your lookup table MUST BE SORTED
on the lookup column, ascending, or you may get an unexpected result.
2) If you use FALSE for the 4th argument, you are telling VLOOKUP to find an exact match.  In this case, your
lookup table does not have to be sorted, but if there is no exact match, the function returns an #N/A error

Without looking at Rory's formula, I used this for Calculation!C2, copied down through the end of the range:

=VLOOKUP(VLOOKUP(B2,Info!B:C,2,FALSE),'Risk Criteria'!$C$3:$E$7,3,TRUE)

If Rory used the same formula, then he should get the points :)
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 24366287
kbrasco,

BTW, I also resorted the table on the Risk Criteria sheet, so that the lowerbound is sorted ascendingly.

Regards,

Patrick
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

618 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