price quotes based on age range - dynamic

I have a question to pick insurance rates. In one column I have age ranges and the next column i have corresponding rates. The rate is based on the age range. When I enter a birthdate, the correct rate (based on age range) gets displayed in another cell. I need a formula....
I'm stuck.... When you enter a birthdate in cell E3, an age will be calculated and pull the correct rate from a list.... For instance:
18-24 $342.02
25-29 $359.42
30-34 $408.35 birthdate 10/29/1971
35-39 $428.28
40-44 $459.82 Rate $687.06
45-49 $546.07
50-54 $687.06
55-59 $862.84
60+ $1,020.85

Related

index return data value between two dates and additional criteria

index-match-multiple-criteria
I want to extract the transactions from column H that match the specific product in column J, but at the same time, it should match location 65 location data is in column A the attached picture show the full data details.
currently I'm using =INDEX($H:$H,MATCH(1,(($B:$B=J2)($D:$D>=$K$3)($D:$D<=$L$3)),0))
how can I expand the above index formula to include the specification of location 65
the formula should return the transactions that were made between two dates k3 start date and L3 end date for each product line in the J column and also those transactions should be made by 65 location from the data given at column A
I really need your help on this I have been looking for a resolution to my request.

(VBA) Extract and copy and paste column values for specified date range for corresponding row values

I've been stuck on this for a while now. What I need is the title - what I have is:
Sheet 1:
1 billion mostly unnecessary columns.
Column D: Values I need Column F: Column M:
Revenue Names Date
12 John 1/24/2016 2:40:02 AM
15 Sarah 3/2/2016 4:35:17 PM
14 Sarah 7/17/2016 1:50:10 PM
20 Matt 8/20/2012 4:16:12 AM
10 John 11/19/2015 5:04:05 AM
etc. etc.
Current Sheet 2: Pivot Table*
Row Label:
Sarah
Matt
John
etc.
Desired Sheet 2 Pivot Table+*
Row Label: Column __:
Revenue
Sarah 29
Matt 0 *(note: see below, but = 0 because Matts value corresponded to date 2012)
John 22
etc.
The important thing about Sheet 2 is that I would like to tell VBA to find the nearest emptiest column within the sheet, and input the values from Column D from S1 (and sum for duplicates) but only sum and extract values that range from today's date to 11 months prior. Currently I made a module to automatically create a pivot table for the next sheet, but I have wanted to add the above for a while, just stuck.
I'm also assuming I won't have to specify sum if I tell VBA to extract data for corresponding row label names? And I was thinking about putting a Begin Date and End Date cells on Sheet 2 to refer to, or using the TODAY() function somehow for the date, but not sure how to specify to extract and sum values for the date range from today to 11 months prior.
Edit: *Please note this is a watered down version of my current situation, everything is bigger so to avoid confusion, pivots are necessary, but I choose to dilute it for the sake of this issue.
Do you really need a pivot table?
If you dont, just create a new sheet with all the names, set a cell for the starting date you want to consider and do =sumifs
For example
On Sheet2 B1 you put 1/24/2016.
Then on A2 you insert the name (Sarah, for example)
On B2 you put the formula
=Sumifs(Sheet1!D:D,Sheet1!F:F,A2,Sheet1!M:M,">"&B$1)
After that just make a list of name and drag the formula beside every name.
*My excel is in portuguese so maybe the formula needs some other ajustments to work.

How to change the row values and column values in excel vba

Hi I am very new to Excel VBA
I want to change row and column values
My data is similar to this
My age is My height is My weight is
between 10-20 150 45
between 21-30 170 56
between 10-20 155 60
between 10-20 160 53
between 21-30 173 68
I want to make the data like this
Age Hght Wght
Category A 150 45
Category B 170 56
Category A 155 60
Category A 160 53
Category B 173 68
ie I changed the first row
Then I changed all "between 10-20" to "Category A" and "between 21-30" to "Category B"
I prefer not to use column numbers in code, instead I prefer to use column names.
ie like this,
If Age="between 10-20" then Age="Category A"
How can we do it?
First of all, make sure you put the data in the table. (not simply type in the data in the excel's cells) You should go to INSERT ribbon there insert the table.
Next, follow the advice from #Bryon, create another table called "DataTable" like following figure. You may create this table at another worksheet (e.g. MyData)
Lastly, you create another table called "MyResult". At the 1st row of the table, put the formula in the cell as following based on the columns :
=VLOOKUP(AgeTable[#[My age is]],DataTable,2,TRUE)
column 2
=VLOOKUP(AgeTable[#[My Height is]],AgeTable[#[My Height is]],1,TRUE)
column 3
=VLOOKUP(AgeTable[#[My Weight is]],AgeTable[#[My Weight is]],1,TRUE)
Following is the output of the table:
Whenever values had been change at column 2 and column 3 of table 1, it will change the column 2 and column 3 of table 3

Divide rows and then transfer divided values in new worksheet (values: time periods & amounts)

Hope you can help with this:
In worksheet "TOTALS" and Range "M11:N251" there are "from:to" time periods inserted by user ("From" is in "M11:M" and "To" is in "N11:N"). Number of rows (and inserted time periods) may vary. Time periods are quadrimester (4months) but not always 120 days (could be 119, 122 or sth like that - if less than 100 then user must not be allowed to divide). Range "W11:W251" hosts amounts of money. So, for example, "M11:N11" can be 1/1/13-1/5/13 (dd/mm/yy) and W11 just a number (i.e. 98,45).
I want to be able to divide each time period almost by 2 (first part can be 60 days, second part rest of days) and amounts accordingly (depending on the number of days of its divided period) and transfer the divided periods and amounts to a new worksheet (TOTALS2) to -let's say- range "A11:B251" & "G11:G251").
So, in the above example, in "TOTALS2" we'll have 1/1/13-1/3/13 in "A11:B11" and 1/3/13-1/5/13 in "A12:B12", and the divided amounts accordingly to the counted days of "A11:B11" & "A12:B12" in "G11" and "G12".
And so on until there are no more time periods & amounts in TOTALS to divide and transfer to TOTALS2.
How can this be done? Ideas?
Thanks in advance!
If you want to check out the file, then download it:
http://www.sendspace.com/file/5kudcy
Based on the file you give in your link where the values in TOTALS start at row 10 (rather than 11 as stated), the prices are in column S (rather than W as stated) and the values in TOTALS2 are to appear in row 10 onwards (rather than row 11 onwards as stated) the following approach works:
Add 5 columns to worksheet TOTALS. These 5 columns have a header in row 9 and formulae in rows 10, 11, 12, etc. Using columns X, Y, Z and AA the header values in X9:AB9 are
Period, Int.To, Int.From, Proportion1, Proportion2
(where Int. is an abbrevation for intermediate.)
The formulae to use in cells X10 to AB10 are:
X10: =N10-M10+1 Calculates number of days from date M10 to date N10, inclusive.
Y10: =M10+59 Calculates end date of the 60 day period starting on date M10 (i.e calculates last date of first "half period")
Z10: =1+Y10 Calculates day after date in Y10 (start date of second "half period")
AA10: =60/X10 Proportion of whole period that is accounted for by first half-period
AB10: =1-AA10 Proportion of whole period that is accounted for by second half period
The formulae in X10:AB10 can be copied down for as many rows as contain data in worksheet TOTALS, to get something like...
The additional columns in TOTALS now provide the information that you need to split each quadrimester into two "halves". Cols M, N, Y and Z provide the date information and S, AA and AB the values for splitting each quadrimester's costs. To get it to display as desired in TOTALS2 you will also need to add a couple of columns to TOTALS2. I've used columns L and M with the following headers in L9 and M9:
Source, Part
In both L10 and L11 insert the value 1, whilst in M10 and M11 insert the values 1 and 2, respectively. Now add the following formulae to L12 and M12
L12: =1+L10
M12: =M10
Copy the formulae in L12 and M12 down so that columns L and M contain values in at least twice the number of rows (in TOTALS) that you wish to split into first half and second half periods. You should end up with the sequence 1,1,2,2,3,3,4,4 etc in column L and 1,2,1,2,1,2,1,2 etc in M.
The Source column (L) indicates which data row in TOTALS (1=first, 2=second, 3=third, etc) acts as the source of the values to be split in "half" and the Part column (M) indicates which "half" it is (1=first, 2=second).
All that remains is to put it all together using appropriate formulae in columns A, B and G of TOTALS2. The formulae to insert into A10, B10 and M10 are:
A10: =OFFSET(IF(M10=1,TOTALS!M$9,TOTALS!Z$9),L10,0)
B10: =OFFSET(IF(M10=1,TOTALS!Y$9,TOTALS!N$9),L10,0)
G10: =OFFSET(TOTALS!S$9,L10,0)*OFFSET(TOTALS!Z$9,TOTALS2!L10,M10)
Copy these formulae down the rows in TOTALS2 and it should be looking like...
The formulae in col A pick the start dates of the "half" periods using either col M or col Z from the correct Source row in TOTALS, according to whether the Part value is 1 or 2. Similarly, the formulae in col B pick the end dates using cols Y and N of TOTALS. The formulae in G multiply the cost value (col S of TOTALS) by the correct proportion from either col AA or col AB in TOTALS, again according to whether Part is 1 or 2.
I haven't included refinements such as:
preventing periods which are too short (or long) in TOTALS from being split (hint: you can detect this using the Length column in worksheet TOTALS) or
controlling the number of displayed rows in TOTALS2 so that it is exactly twice the number of data rows entered in TOTALS (not too difficult and several ways it can be approached) or
rounding the calculated costs for the two "halves" to 2 decimal places AND making sure that they add back to the original quadrimester cost (it is formatting in the worksheet that is causing only 2 decimals to be displayed and it is not guaranteed that the displayed values will sum precisely to their original source cost - the examples chosen just happen to have this property. Again not too difficult to solve.)
However, the above is a basic solution on which you can build.

Any ideas how to determine what age group an individual belongs in Excel?

I have 2 columns in an Excel spread sheet.
First column header is called AGE and the second column header is called Age_Group.
The ages in the AGE column are between 18 and 45.
There could be multiple rows with same age.
I am tasked with determining what age group a certain age falls into and then print out that age group.
For instance, if someone’s age is 18, I would like to use IF statement or CASE statement to determine that age 18 is between 18 and 24 and then put that value into Age_Group column as 18-24.
If age is 19, again, it will fall into the group of 18-24 in Age_Group column.
If the age in the Age column falls between 25 and 29, then they will be in Age_Group column as 25-29.
Here is an example:
AGE AGE_GROUP
18 18-24
19 18-24,
25 25-29
28 25-29
If you would be kind to share some code, I can use it to calculate the rest till we reach 45.
I am not good with Excel VBA. Any assistance with IF or CASE statement would be greatly appreciated.
Use a vlookup. Create a two column table with the lower bound of your age range in the first column and the age range as text in the second column like so:
AGE_LOOKUP AGE_GROUP
18 18-24
25 25-29
30 30-35
36 36-37 etc..
Name this table's range as AGE_GROUP_TABLE then using the following formula to get the age group:
VLOOKUP(A1, AGE_GROUP_TABLE, 2, TRUE)
Put different ages into cell A1 and the formula will return the correct age group. The important thing to remember is to make sure that the last parameter of the VLOOKUP is set to TRUE, this makes the VLOOKUP find the nearest match.
Here is a VBA code: But surely you are better off with that Excel VLOOKUP. :)
First add module to a VBA project.
Copy the following
code.
Option Explicit
Function whatAgeGroup(ByVal i As Integer) As String
Select Case i
Case IsEmpty(i)
whatAgeGroup = "No Age Entered"
Case 18 To 24:
whatAgeGroup = "18-24"
Case 25 To 29
whatAgeGroup = "25-29"
Case 30 To 34
whatAgeGroup = "30-34"
Case 35 To 39
whatAgeGroup = "35-39"
Case 40 To 44
whatAgeGroup = "40-44"
Case Is >= 45
whatAgeGroup = "45 and Above"
Case Else
whatAgeGroup = "WhatGroup?"
End Select
End Function
enter the function name in a cell and enter, as per the image shown.
As the idea of a Table was causing some confusion I thought I would also share my favourite trick of a self contained, table free, VLOOKUP using an embedded array. So for the current problem it would look something like this:
VLOOKUP(A1, {18,"18-24";25,"25-29";30,"30-35";36,"36-37"}, 2 TRUE)
While the vlookup solution is excellent, you can also do that with a PivotTable. Make sure the age is the row heading, then right click the Age "square" and select Group. This is avery easy and dynamic.