Using multiple OFFSET & MATCH formulas beyond the 1st instance

TimX81

New Member
Joined
May 17, 2011
Messages
5
Hi, I'm having trouble using OFFSET and MATCH to find matches beyond the first instance of a match. The root of the problem is the match_type selection. Between selecting a match_type of 1 and 0, I'll either match the wrong value, or return an error. The solution is probably very simple, so I apologize for the litany of reference material below. I run Excel 2007.

My worksheet is supposed to check whether a promotion is active by looking for a matching tag. Assuming there is a match, the formula needs to calculate the promotional price x # of months in the promotion.

In general, the current worksheet layout is as follows:
-Tags for standard price elements running along a header row (e.g., StandardMonthlyPrice)
-An array of values below the header row with prices
-A section for promotional elements running along the far right of that header row
-An array of values below the far right of the header row, where up to 12 different promotions can be entered, where a tag like StandardMonthlyPrice can be entered in one column, with columns for promotional price, promo. start month, and promo. end month to adjust the calculation of monthly prices

An excerpt from my formula is below. To establish whether the tag at FM3 matches a promotion, the formula checks whether that tag exists in SL8, and then has offsets to gather the price in SM8, the start month in SP8, and the end month in SQ8. The formula repeats with offsets spaced 12 columns apart thereafter, since additional promotions can be entered in each row:

=IF(ISNA(MATCH(FM$3,$A8:$SL8,0)),0,OFFSET($A8,0,SUM(MATCH(FM$3,$A8:$SL8,0)))*(OFFSET($A8,0,SUM(MATCH(FM$3,$A8:$SL8,0),4))+1-OFFSET($A8,0,SUM(MATCH(FM$3,$A8:$SL8,0),3))))+IF(ISNA(MATCH(FM$3,$SM8:$SX8,0)),0,OFFSET($A8,0,SUM(MATCH(FM$3,$A8:$SL8,0),12))*(OFFSET($A8,0,SUM(MATCH(FM$3,$A8:$SL8,0),12+4))+1-OFFSET($A8,0,SUM(MATCH(FM$3,$A8:$SL8,0),12+3))))+[...]

Let's say that the tag in FM3 is matched not at SL8, but 12 columns to the right in SX8 (expressed as the "12" offset above). Meanwhile, SL8 is non-blank, with a different tag entered. The formula will return an #N/A! error.

I'll be very grateful for any suggestions toward reworking the formula. Thank you!
 
Ok, now I've seen the data layout, I think I have this figured out, the suggestion I gave previously would only work if the formula was going to the left of the data, or in a different row / sheet, with the current layout that causes a circular reference, which could be fixed by allowing it in the options but it's better to avoid it.

Note these formula need to be array confirmed with Shift Ctrl Enter, if you get the result #VALUE! then it means the array has not been entered correctly.

In XY8 enter =SUM(IF(SL8:XN8=$FM$3,SM8:XO8*(SQ8:XS8+1-SP8:XR8)))
In XY9 enter =SUM(IF(SL8:XN8=$JK$3,SM8:XO8*(SQ8:XS8+1-SP8:XR8)))

Then use autofill to copy down as needed.

Results I get on the sample

<TABLE style="WIDTH: 96pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=128><COLGROUP><COL style="WIDTH: 48pt" span=2 width=64><TBODY><TR style="HEIGHT: 58.5pt; mso-height-source: userset" height=78><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; WIDTH: 48pt; HEIGHT: 58.5pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" class=xl64 height=78 width=64 align=right>479.88</TD><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext; BACKGROUND-COLOR: transparent; WIDTH: 48pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" class=xl64 width=64 align=right>18</TD></TR><TR style="HEIGHT: 58.5pt; mso-height-source: userset" height=78><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; HEIGHT: 58.5pt; BORDER-TOP: windowtext; BORDER-RIGHT: windowtext 0.5pt solid" class=xl64 height=78 align=right>359.88</TD><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext; BACKGROUND-COLOR: transparent; BORDER-TOP: windowtext; BORDER-RIGHT: windowtext 0.5pt solid" class=xl64 align=right>11.94</TD></TR><TR style="HEIGHT: 58.5pt; mso-height-source: userset" height=78><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; HEIGHT: 58.5pt; BORDER-TOP: windowtext; BORDER-RIGHT: windowtext 0.5pt solid" class=xl64 height=78 align=right>119.94</TD><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext; BACKGROUND-COLOR: transparent; BORDER-TOP: windowtext; BORDER-RIGHT: windowtext 0.5pt solid" class=xl64 align=right>0</TD></TR></TBODY></TABLE>
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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