Formula Help Needed

excel_training_wheels

Board Regular
Joined
Aug 25, 2005
Messages
193
Hi--

I have three main columns of data. Column A includes city names. Column B includes hotel names. Column C includes random numbers. I am trying to have excel return the number associated with the second occurance of a given hotel in each of my cities.

Boston Days Inn 1
Boston Hyatt 2
Boston Days Inn 3
Boston Hilton 4

I want the formula to return the number *3* associated with the second Days Inn, within Boston.

So I inserted a column C (at the advice of a fellow board member who helped me yesterday!!) that connects Boston with Days Inn (=A2&B2). I also put the city name in F2 and hotel name in G2.

The formula in H2:
=VLOOKUP(F2&G2,C1:D11,2,0)

This returns *1* for the first occurance of Days Inn in Boston, which is great. However, now I want to adjust so that *3* is returned, for the second occurance. I can not re-sort the data...it has to stay as is.

Thanks for your help!!!!!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
excel_training_wheels said:
Hi--

I have three main columns of data. Column A includes city names. Column B includes hotel names. Column C includes random numbers. I am trying to have excel return the number associated with the second occurance of a given hotel in each of my cities.

Boston Days Inn 1
Boston Hyatt 2
Boston Days Inn 3
Boston Hilton 4

I want the formula to return the number *3* associated with the second Days Inn, within Boston.

So I inserted a column C (at the advice of a fellow board member who helped me yesterday!!) that connects Boston with Days Inn (=A2&B2). I also put the city name in F2 and hotel name in G2.

The formula in H2:
=VLOOKUP(F2&G2,C1:D11,2,0)

This returns *1* for the first occurance of Days Inn in Boston, which is great. However, now I want to adjust so that *3* is returned, for the second occurance. I can not re-sort the data...it has to stay as is.

Thanks for your help!!!!!
Book3
ABCDEFGH
1
2BostonDays Inn1BostonDays Inn23
3BostonHyatt2
4BostonDays Inn3
5BostonHilton4
6
Sheet1


H2:

=INDEX($C$2:$C$5,SMALL(IF($A$2:$A$5=E2,IF($B$2:$B$5=F2,ROW($C$2:$C$5)-ROW($C$2)+1)),G2))

which must be confirmed with control+shift+enter, not just with enter.
 
Upvote 0
excel_training_wheels

Just for the fun of it, here's a way without the array formula, but still with the extra column like my answer to your previous thread.

The formula in C2 (copied down) is now:
=A2&B2&SUMPRODUCT(--(A$2:A2=A2),--(B$2:B2=B2))

The formula in I1 is:
=F2 & " "&G2&" Occurrence "&H2

The formula in I2 is now:
=VLOOKUP(F2&G2&H2,C1:D11,2,0)
Mr Excel.xls
ABCDEFGHI
1CityHotelNumberCityHotelOccurrenceMemphis Hyatt Occurrence 2
2BostonDays InnBostonDays Inn11MemphisHyatt24
3BostonDays InnBostonDays Inn22
4BostonHiltonBostonHilton13
5BostonHyattBostonHyatt14
6BostonHyattBostonHyatt25
7MemphisHiltonMemphisHilton16
8MemphisHyattMemphisHyatt18
9MemphisTravel 1MemphisTravel 119
10MemphisHyattMemphisHyatt24
11MemphisHyattMemphisHyatt31
City_Hotel (2)
 
Upvote 0
Peter_SSs said:
excel_training_wheels

Just for the fun of it, here's a way without the array formula, but still with the extra column like my answer to your previous thread.

The formula in C2 (copied down) is now:
=A2&B2&SUMPRODUCT(--(A$2:A2=A2),--(B$2:B2=B2))

The formula in I1 is:
=F2 & " "&G2&" Occurrence "&H2

The formula in I2 is now:
=VLOOKUP(F2&G2&H2,C1:D11,2,0)
...

An expensive fun... BTW, a SumProduct formula operates on arrays just like a formula confirmed with control+shift+enter does.
 
Upvote 0

Forum statistics

Threads
1,223,969
Messages
6,175,680
Members
452,667
Latest member
vanessavalentino83

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