Looking for Feedback or Previous Experience on My Article on Scripting.Dictionary

Alex20850

Board Regular
Joined
Mar 9, 2010
Messages
146
Office Version
  1. 365
Platform
  1. Windows
A Lookup Function Across Spreadsheets

How did this function come to be and what does it do?

I was working on a project comparing the statistics of states in pivot tables. Most of the information I found used state names, but for pivot tables I wanted to use their abbreviations. I got tired of using VLOOKUP whenever I needed to switch a state name to its abbreviation or back again. That’s where this custom function came in.

This is an example of what people came up with. It works like a VLOOKUP, but is available across all spreadsheets. It can be text, number or dates.

I have not been able to add more than 3,000 lines per function. I have been able to several functions of 3,000 lines.

Function Retrieve(ByVal str As String) As String
With CreateObject("Scripting.Dictionary")
.Add "AL", "Alabama"
.Add "AK", "Alaska"
.Add "Alabama-P","4,875,000"
Add “adate”,”01/01/2018”
'Although population is shown in quotes, it comes into Excel
‘as a number
If .exists(str) Then Retrieve = .Item(str)
End With
End Function

The function can refer to a cell as in RETRIEVE(B1) or may be hard-coded, i.e. RETRIEVE(“AL”).

Notes:

  1. The before value is case-sensitive when used in the spreadsheet in a formula, i.e. =retrieve(
  2. The before and after values must both be in quotes.
 

Excel Facts

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

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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