UDF producing #NAME?

J

Jim May

Both these functions are yielding/displaying the #NAME?
in cell A1 which contains either =ColumnLetter(AB5) or ColumnLetter($AB$5)
or
ColLetter(AB5) or ColLetter($AB$5)..
Any ideas as to why?
Thanks in Advance

Function ColumnLetter(Rng As Range) As String
ColumnLetter = Left(Rng.Range("A1").Address(True, False), _
InStr(1, Rng.Range("A1").Address(True, False), "$", 1) - 1)
End Function


Function ColLetter(Rng As Range) As String
ColLetter = Left(Rng.Address(False, False), _
1 - (Rng.Column > 26))
End Function
 
H

Hank Scorpio

Both these functions are yielding/displaying the #NAME?
in cell A1 which contains either =ColumnLetter(AB5) or ColumnLetter($AB$5)
or
ColLetter(AB5) or ColLetter($AB$5)..
Any ideas as to why?
Thanks in Advance

Best guess; you have the function definitions in a different workbook
from the workbook that you have the formulas in.

If the functions below are in your Personal.xls workbook (say), then
this:
=PERSONAL.XLS!ColumnLetter(AC15)

should work, but this:
=ColumnLetter(AB5)

gives me the result you describe.

You might also consider saving the functions into an add-in. (.xla)
 
J

Jim May

Hank - Thanks,,,
CRAP!! -- I had them both in my Sheet1 module
versus a Standard Module..
Thanks,
Jim
 
B

Bob Phillips

Hi Jim,

Another version for you :)

Function ColumnLetter(rng As Range) As String
ColumnLetter = Split(Columns(rng.Column).Address(, False), ":")(1)
End Function


--

HTH

RP
(remove nothere from the email address if mailing direct)


Jim May said:
Hank - Thanks,,,
CRAP!! -- I had them both in my Sheet1 module
versus a Standard Module..
Thanks,
Jim
 
J

Jim May

Thanks Bob, I've added it to my file(s).
Jim

Bob Phillips said:
Hi Jim,

Another version for you :)

Function ColumnLetter(rng As Range) As String
ColumnLetter = Split(Columns(rng.Column).Address(, False), ":")(1)
End Function


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top