Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Passing a string to a function instead of a cell reference

Currently using excel2003 with the following UDF

Function EmpName(nam3 As String)
Select Case nam3
Case "John"
EmpName = "First"
Case "Doe"
EmpName = "Last"
End Select
End Function

This works if I use a cell reference i.e. A1=John, =EmpName(A1) but fails if
I use =EmpName(John). I can get both forms to work if I am passing a number
and evalualting the case as a number. How do i get it to use =EmpName(John)?

Thank you in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 905
Default Passing a string to a function instead of a cell reference

"rbennu" wrote:
How do i get it to use =EmpName(John)?


=EmpName("John")

just you use strings in any Excel formula.


----- original messages -----



"rbennu" wrote:
Currently using excel2003 with the following UDF

Function EmpName(nam3 As String)
Select Case nam3
Case "John"
EmpName = "First"
Case "Doe"
EmpName = "Last"
End Select
End Function

This works if I use a cell reference i.e. A1=John, =EmpName(A1) but fails if
I use =EmpName(John). I can get both forms to work if I am passing a number
and evalualting the case as a number. How do i get it to use =EmpName(John)?

Thank you in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Passing a string to a function instead of a cell reference

Much Thanks!

"Joe User" wrote:

"rbennu" wrote:
How do i get it to use =EmpName(John)?


=EmpName("John")

just you use strings in any Excel formula.


----- original messages -----



"rbennu" wrote:
Currently using excel2003 with the following UDF

Function EmpName(nam3 As String)
Select Case nam3
Case "John"
EmpName = "First"
Case "Doe"
EmpName = "Last"
End Select
End Function

This works if I use a cell reference i.e. A1=John, =EmpName(A1) but fails if
I use =EmpName(John). I can get both forms to work if I am passing a number
and evalualting the case as a number. How do i get it to use =EmpName(John)?

Thank you in advance

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
passing cell reference and formatting cell in VBA function graham_s Excel Programming 3 April 15th 09 11:09 AM
error passing a formula to a cell from a string TheIrishThug[_10_] Excel Programming 3 December 22nd 05 03:54 PM
Passing Cell Address (String or Range) ExcelMonkey[_190_] Excel Programming 6 March 16th 05 05:11 PM
Passing a string aray as an argument to a function ?....Help! Dan Thompson Excel Programming 5 September 29th 04 03:01 AM
passing reference arguments to VBA function Mezon Excel Programming 2 August 28th 04 04:49 PM


All times are GMT +1. The time now is 10:05 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"