Multiple CASEs: Best Practices, Arrays?

Sphinx404

Board Regular
Joined
May 2, 2015
Messages
186
Office Version
  1. 365
Platform
  1. Windows
Hello and thank you for offering your help.

I have 2 columns I have to compare and match. Cities and Airport Codes

Each column is user defined (input by user, not pulled out of a static environment/system) which adds some tricky coding.

1. There are over 200 airport codes in this particular report (probably not a great idea to write CASE, CASE ELSE code in this circumstance).

2. Each column is user defined, so if I am going to match, for example, MSP to MINNEAPOLIS, I have to account for people who define the city as "Minneapolis, MINNEAPOLIS, Minneapolis-St. Paul, Minneapolis-Saint Paul, Saint Paul, Minneapolis/St.Paul" etc. etc. etc.

3. Once I match MSP with one of its many forms of corresponding city definitions, I need "mycell" to return "True"

I've seen some code that is way over my head, but was wondering if it shows any promise or if you all have a better idea? Pull the codes and cities out of a table? But then how does one account for the multiple ways a user can define the city?

Here's part the "Way over my head" code:

Code:
'Dim acrArray
'Dim mycell As Range
'Dim myrange As Range


'acrArray = Array("ATG", "MSP", "DTW", "")


'For Each mycell In Range("V2", Range("V" & Rows.Count).End(xlUp))
'For Each myrange In Range("A2", Range("A" & Rows.Count).End(xlUp))


'For i = LBound(acrArray) To UBound(acrArray)


'    If (StrComp(mycell, acrArray(i)) + StrComp(myrange, acrArray(i)) > 0) Then
'        mycell.Value = "True"
'            i = UBound(acrArray) + 1
'    End If


'Next i


'Next myrange
'Next mycell

Don't ask me about the code... I have no clue, but if any of you Excel MVPs, Pro and kings of coding can help, I'd be grateful. Thanks.
 
Last edited:

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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