ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need a method or function (https://www.excelbanter.com/excel-programming/306376-need-method-function.html)

Eric Marple

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


patrick molloy

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

.


Soo Cheon Jheong[_2_]

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
_ _
^вп^
--




All times are GMT +1. The time now is 07:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com