Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Looking for a better way - Serial to local machine number

I have a list of machine serial numbers from a national database that I want
to change to a local number in a UDF. Right now I am using a Select Case
statement to do that. This works fine for the small set I'm using right now.
However, I would like to expand this to a larger set of numbers. What would
be the best way to do this?

Thanks - Mike

Select Case vDecSerial
Case 53: vLocal = 1
Case 72: vLocal = 2
Case 95: vLocal = 3
Case 114: vLocal = 4
Case 162: vLocal = 5
Case 2044: vLocal = 6
Case 2068: vLocal = 7
Case 2346: vLocal = 8
End Select

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Looking for a better way - Serial to local machine number

Maybe you could put the data in a hidden worksheet. And use =vlookup() to
return the value you need.

dim TableLookup as Range
dim vLocal as variant 'could return an error

set tableLookup = worksheets("sheet9999").range("a:b")

res = application.vlookup(vDecSerial, tablelookup,2,false)
if iserror(res) then
'not found
vLocal = 9999999 'what should happen?
end if




mikebres wrote:

I have a list of machine serial numbers from a national database that I want
to change to a local number in a UDF. Right now I am using a Select Case
statement to do that. This works fine for the small set I'm using right now.
However, I would like to expand this to a larger set of numbers. What would
be the best way to do this?

Thanks - Mike

Select Case vDecSerial
Case 53: vLocal = 1
Case 72: vLocal = 2
Case 95: vLocal = 3
Case 114: vLocal = 4
Case 162: vLocal = 5
Case 2044: vLocal = 6
Case 2068: vLocal = 7
Case 2346: vLocal = 8
End Select


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Looking for a better way - Serial to local machine number

Thank you Dave,

That should work.



"Dave Peterson" wrote:

Maybe you could put the data in a hidden worksheet. And use =vlookup() to
return the value you need.

dim TableLookup as Range
dim vLocal as variant 'could return an error

set tableLookup = worksheets("sheet9999").range("a:b")

res = application.vlookup(vDecSerial, tablelookup,2,false)
if iserror(res) then
'not found
vLocal = 9999999 'what should happen?
end if




mikebres wrote:

I have a list of machine serial numbers from a national database that I want
to change to a local number in a UDF. Right now I am using a Select Case
statement to do that. This works fine for the small set I'm using right now.
However, I would like to expand this to a larger set of numbers. What would
be the best way to do this?

Thanks - Mike

Select Case vDecSerial
Case 53: vLocal = 1
Case 72: vLocal = 2
Case 95: vLocal = 3
Case 114: vLocal = 4
Case 162: vLocal = 5
Case 2044: vLocal = 6
Case 2068: vLocal = 7
Case 2346: vLocal = 8
End Select


--

Dave Peterson

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
Hyperlinks do not work on local machine. Andrew Links and Linking in Excel 7 June 19th 06 11:11 PM
Counting&Sorting multiple serial numbers per machine type Dark_Templar Excel Discussion (Misc queries) 5 June 17th 06 09:06 AM
Reference & update destin. cells on 1st machine from source workbook on 2nd machine. [email protected] Excel Discussion (Misc queries) 6 February 28th 06 05:15 AM
How to access a database on a server from a local machine using od Todd W Excel Discussion (Misc queries) 0 December 15th 05 03:16 PM
Move Folders on the Server vs. Local Machine Myrna Rodriguez[_2_] Excel Programming 1 May 26th 05 06:26 PM


All times are GMT +1. The time now is 06:22 AM.

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"