Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Need a method or function

I need to pass in either a letter or a number and
retreive a letter or number, Example A=1, B=2, C=3, D=4
Or 1=A,2=B,3=C,4=D
Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Need a method or function

with two textboxes and a command button on a userform,
add this code...

Private Sub btnProcess_Click()
Dim letter As String
Dim value As Variant

If Trim(TextBox1.Text) = "" Then Exit Sub

If IsNumeric(TextBox1) Then
value = Chr(CLng(TextBox1.Text) + 64)
Else
value = Asc(TextBox1.Text) - 64
End If

TextBox2.value = value

End Sub

enter a letter or a number in textbox1, click the button
and see what appears in textbox2..

A .... 1
Z ... 26
17 ... Q

Patrick Molloy
Microsoft Excel MVP


-----Original Message-----
I need to pass in either a letter or a number and
retreive a letter or number, Example A=1, B=2, C=3, D=4
Or 1=A,2=B,3=C,4=D
Thanks

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Need a method or function

Hi,

Function LT(ByVal V As Variant) As Variant

V = Trim(V)
If IsNumeric(V) Then
If V = 1 And V <= 26 Then
LT = Chr(V + 64)
Else
LT = ""
End If
ElseIf V Like "[A-Z]" Or V Like "[a-z]" Then
LT = Asc(UCase(V)) - 64
Else
LT = ""
End If

End Function


--
Regards,
Soo Cheon Jheong
_ _
^ąŻ^
--


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
Forecast function calculation method? Kayote New Users to Excel 1 April 10th 06 10:23 AM
method and function mango Excel Worksheet Functions 0 December 14th 04 11:51 PM
Function or method Eric Marple Excel Programming 1 August 5th 04 05:48 PM
Calling a module function from a class method ranafout[_2_] Excel Programming 1 November 12th 03 11:08 AM
Method? Function? Operator? I dunno ): Michael Smith Excel Programming 0 September 5th 03 09:47 PM


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