VLookUp containing Offset error

Wayne's Wisdom

New Member
Joined
Jan 10, 2014
Messages
8
Hi All,

Using Office Jhome and Business 2010 and Windows 7 Pro.

I found similar questions but they don't fit my scenario. In the long run this will be part of a macro but I first need it to work as a formula in a cell. I don't know if this is the best way or even a suitable method but it's the only solution i can think of.

I have a sheet that will calculate the commission due for staff. The staff member may at some point be upgraded to a new commission structure or percentage but payment is calculated around the time the business was introduced.

First I have a staff index sheet, column A is staff Id, Column B counts from 1 (Currently over 400 and growing)
Staff IDIndex
1000011
1000042
1000073
1000104
1000135
1000166
1000197

<colgroup><col><col></colgroup><tbody>
</tbody>
Then I have a LookUp sheet. Column B is a regular vlookup. Column C countifs for staff Id. Column D is start date at company. Column D is a date on which their commission changed to a new structure. Column E is blank for most(only used when staff member leaves company). Column F is a commission code reference that looks up the commission formula to be used. Column G is currently copied from the third sheet. The third sheet is a report of sales and another column will take the data from column G do a lookup for the commission formula and then calculate the commission to be paid. The date of the business done determines the commission to be paid. If a deal happened a year ago and commission is now due then the commission paid is according to the code they were on when the business was agreed to and so needs to reflect the code of that period.
Column AColumn BColumn CColumn DColumn EColumn EColumn FColumn G
Staff IdIndexNumberofArrangementsStart DateComm Change DateLeave DateCommissionCodePolicyCommCode
100001122010/05/172010/05/1711
100001122010/05/172011/05/17 21
100004212010/05/172010/05/173#N/A
100007312010/05/172010/05/1713
100010412010/05/172010/05/1721
100013512010/05/172010/05/1732
100016612010/05/172010/05/1713
100019712010/05/172010/05/1722
100022812010/05/172010/05/1711

<colgroup><col span="2"><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>

<colgroup><col span="2"><col><col><col><col><col><col></colgroup><tbody>
</tbody>

On report sheet each row represents a deal and takes the staff Id and looks for the commission code on lookup sheet. it is dependent on the date of the business.

Eg. businees done on 2010/12/01 for Id 100001 should yield "1" (column F) but for the same Id business done on 2011/12/01 should yield a "2".

Formulas on sheet 2:
Column A: None
Column B: =VLOOKUP(A2,Index_Sheet!$A:$B,2,FALSE)
Column C: =COUNTIFS(A:A,A2)
Column D - F: None
Column G: =VLOOKUP(K2,OFFSET(LookUPSheet!$E$2,B2-1,0,C2,3),3,TRUE)

I think the problem lies in my offset row. I get the wrong code or an #N/A error.

Please assist me.
Wayne
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
why you are using TRUE in the vlookup? are you intended to have approximate match? if that's the case, the data in Column E should be sorted in ascending order.

If you need exact match actually, change the TRUE to FALSE
 
Upvote 0
I am using true because it's a date and I am looking for the date (of the comm structure) which is the closest preceding date to the date of the business. So basically I am looking for the comm structure of a staff Id that was valid before the date of the transaction.

Also, I assume you are correct and that's why I have sorted the data in COLUMN A in ascending. The dates for a particular Id will automatically be sorted ascending. The Offset needs to only look at the rows of the particular Id in question.
 
Upvote 0
To elaborate:
E.g.
Id 100013 starts at company on 2010/01/01 and is paid on comm structure 7
Gets upgraded to comm structure 2 on 2011/01/01
Gets upgraded to comm structure 5 on 2012/01/01
Today business is concluded and commission is due but the date of transaction is in the first year of employment so the commission is paid on structure 7, a second deal was also concluded today but the transaction date is in the second year of employment so the structure should be that of structure 2. any business from year 3 until today will be calculated as code 5. The array then needs to look at the 3 rows of that id and select the code of the row which the date of transaction precedes that of column E (i.e between dates of column D and E).
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,849
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top