Hlookup

MarkAndrews

Well-known Member
Joined
May 2, 2006
Messages
1,963
Hlookup Example.xls
OPQR
1January
25
312
419
526
633
740
847
954
1061
1168
1275
1382
1489
Sheet1


I have the above hlookup working, however In N1 i would like the month previous from what is selected in O1 (Which is validation list)

What formula should I use?

TIA
 

Excel Facts

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

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
Assuming the list lives in T1:T12,

Code:
=IF(MATCH(O1,T1:T12,0)=1,INDEX(T1:T12,12,1),INDEX(T1:T12,MATCH(O1,T1:T12,0)-1,1))

Denis
 

MarkAndrews

Well-known Member
Joined
May 2, 2006
Messages
1,963
Sorry Denis, I forgot to put where the data comes from
Hlookup Example.xls
ABCDEFGHIJKLM
1JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember
Sheet1
 

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
OK, same logic, just transposed.

Code:
=IF(MATCH(O1,B1:M1,0)=1,INDEX(B1:M1,1,12),INDEX(B1:M1,1,MATCH(O1,B1:M1,0)-1))

Denis
 

MarkAndrews

Well-known Member
Joined
May 2, 2006
Messages
1,963

ADVERTISEMENT

Thanks Denis - Can i just fill this left to get the last 6 months automatically using this formula?

Thanks again
 

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
You can fill it left or right if you use absolute references like this:
Code:
=IF(MATCH(O2,$B$1:$M$1,0)=1,INDEX($B$1:$M$1,1,12),INDEX($B$1:$M$1,1,MATCH(O2,$B$1:$M$1,0)-1))
Interestingly, the months go "backwards" whichever way you fill.

Denis
 

Forum statistics

Threads
1,141,587
Messages
5,707,258
Members
421,498
Latest member
matinebi

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
Top