Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default User defined worksheet functions

Hi

Was wondering if this is an easy thing to do. I have a
mapping table in a spreadsheet, lets say Capital Cities to
Countries so for example you could have Dublin, Ireland.

I want from another spreadsheet to type in my own formula.
For example lets say I type in Dublin to cell A1. In cell
B1 i type a custom created formula eg "=Country(A1)" which
would return Ireland by referencing the mapping table.

I know a vlookup is easier but i want to be to write these
formulas wherever and not have to reference another file.

I am only interested in this if it is a simple piece of
code to write. If these type of things are not then I
won't bother.

Thanks in advance
Kevin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default User defined worksheet functions

Hi Kevin,

Here is one way (using VLOOKUP):

* Define a name - CityCountry - for your mapping table

* Enter the following function in a code module

'-----

Option Explicit

Function Country(cityRef As Range) As String
Country = Application.WorksheetFunction. _
VLookup(cityRef.Value, Range("CityCountry"), 2, False)
End Function

'-----

* As in your example, enter Dublin in A1.

* Then, in any cell, enter =Country(A1)

HTH
Anders Silvén

"kevin" skrev i meddelandet
...
Hi

Was wondering if this is an easy thing to do. I have a
mapping table in a spreadsheet, lets say Capital Cities to
Countries so for example you could have Dublin, Ireland.

I want from another spreadsheet to type in my own formula.
For example lets say I type in Dublin to cell A1. In cell
B1 i type a custom created formula eg "=Country(A1)" which
would return Ireland by referencing the mapping table.

I know a vlookup is easier but i want to be to write these
formulas wherever and not have to reference another file.

I am only interested in this if it is a simple piece of
code to write. If these type of things are not then I
won't bother.

Thanks in advance
Kevin



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Defined Functions MoTrekker Excel Discussion (Misc queries) 2 November 8th 09 06:36 PM
User Defined Functions Mike McLellan Excel Worksheet Functions 2 May 4th 06 10:56 AM
User Defined Functions Jeff B Excel Worksheet Functions 1 April 27th 05 09:59 PM
User Defined Functions Frank@shell Excel Worksheet Functions 3 April 20th 05 02:41 PM
User Defined Functions Tom Waters Excel Programming 1 July 21st 03 12:00 PM


All times are GMT +1. The time now is 09:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"