Dynamic ranges & fancy lookup/index & match - I think?

BruceP

New Member
Joined
Aug 17, 2004
Messages
13
I have a data set of exchange rates that change over time (every week). Date in the first column, the exchange rate in the second and in the third column I have calculated the percentage change relative to the first week - let's call this the 'base week'.

In one cell I have entered a variable which is a percentage (this is named Tolerance) and in another a variable that indicates a number of weeks - I call this value ConsecWeeks.

My challenge: when the percentage change exceeds more than the tolerance for more than the number of ConsecWeeks I want to change the 'base week' exchange rate to that week's exchange rate we are now currently at and calculate the following weeks' percentage change with this new 'base week' exchange rate until the tolerance is exceeded again for the number of ConsecWeeks and then change the base week exchange rate to the value at this new date and so on.

I've worked out a formula that counts the number of weeks that exceed the tolerance using the Tolerance variable and the ConsecWeeks variable

Tolerance is in cell D1, currently set to 2%, and ConsecWeeks is in D2, currently set to 2.

The data headings are in row 4

Here's some sample data.

Date EUR/GBP ABS % change Consecutive weeks of change
01/12/2013 0.8333 0 0
08/12/2013 0.8310 0.28% 0
15/12/2013 0.8152 2.17% 1
22/12/2013 0.8112 2.65% 2
29/12/2013 0.8352 0.23% 2
05/01/2014 0.8308 0.30% 1
12/01/2014 0.8285 0.58% 0
19/01/2014 0.8292 0.49% 0
26/01/2014 0.8248 1.02% 0
02/02/2014 0.7989 4.13% 1
09/02/2014 0.7921 4.94% 2
16/02/2014 0.8232 1.21% 2
23/02/2014 0.8234 1.19% 1
02/03/2014 0.8235 1.18% 0
09/03/2014 0.8260 0.88% 0
16/03/2014 0.8345 0.14% 0
23/03/2014 0.8364 0.37% 0
30/03/2014 0.8310 0.28% 0

The formula that calculates the percentage change from C6 and down the column is =ABS((B6-$B$5)/$B$5)

The formula that counts the number of weeks that the tolerance percentage has been exceeded is =COUNTIF(OFFSET(INDIRECT("R"&ROW()-$D$2&"C"&COLUMN()-1,FALSE),0,0,$D$2+1,1),">"&$D$1)

So, in the above we start with the exchange rate at 0.8333. By the 22/12/2013 we've had two consecutive weeks where the exchange rate has been 2 percent more or less than when we started on 1/12/2013 so from 29/12/2013 I would like the base exchange rate to be 0.8352. The next change would need to happen on 16/02/2014.

I can write the logic down in a crude fashion that says what I want to happen, I just can't work out the formulas needed to achieve it!

I am sure some VBA would be able to achieve this relatively easily but I only have a very basic understanding of VBA and no where near enough to write something that could tackle this.

Is what I want to achieve doable with formulas? I think some form of look up with dynamic ranges is what is needed aided by some helper columns?

My thanks in advance for any comments, suggestions and solutions.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi,

Is the following what you want? Note that the formulas from row 6 are used to fill the spreadsheet. Row 5 is used for initialization.

J.Ty.


Excel 2010
ABCDEFG
1
2
3
4DateEUR/GBPABS % changeConsecutive weeks of changeToleranceConsecWeeksBase
501/12/20130.83330.00%01.00%30.8333
608/12/20130.8310.28%00.8333
715/12/20130.81522.18%10.8333
822/12/20130.81122.71%20.8333
929/12/20130.83520.23%00.8333
1005/01/20140.83080.30%00.8333
1112/01/20140.82850.58%00.8333
1219/01/20140.82920.49%00.8333
1326/01/20140.82481.03%10.8333
1402/02/20140.79894.17%20.8333
1509/02/20140.79215.16%30.8333
1616/02/20140.82321.28%40.8232
1723/02/20140.82340.02%00.8232
1802/03/20140.82350.04%00.8232
1909/03/20140.8260.34%00.8232
2016/03/20140.83451.37%10.8232
2123/03/20140.83641.58%20.8232
2230/03/20140.8310.93%00.8232
Sheet1
Cell Formulas
RangeFormula
D5=0
D6=IF(C6>$E$5,1+D5,0)
C6=ABS((B6-G5)/B5)
G5=B5
G6=IF(D6>$F$5,B6,G5)
 
Upvote 0
Thank you so much. My apologies for not getting back to you sooner. Your solution works perfectly and is far simpler than what I imagined it needed to be.
 
Upvote 0
Thanks for the feedback and good luck!
J.Ty.
 
Upvote 0

Forum statistics

Threads
1,215,684
Messages
6,126,199
Members
449,298
Latest member
Jest

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