View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
patrick molloy patrick molloy is offline
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

.