CODE Function

2077delta

Board Regular
Joined
Feb 17, 2002
Messages
244
Is there a similar function in VBA to Excel's CODE function. I'm importing an ASCII file and it has some unusual characters. What I want to do is identify their Character number and based on that number direct the macro to perform the requiste procedures.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Mudface

MrExcel MVP
Joined
Feb 18, 2002
Messages
3,339
Have a look at the Chr function in VBA help, seems to do the same thing.

Edit:- Ooops, wrong way round :). See Ivan's post below.
This message was edited by Mudface on 2002-09-06 12:22
 

Corticus

Well-known Member
Joined
Apr 30, 2002
Messages
1,579
If you can't find a VBA f(x) for CODE(), you could put the formula in a cell and then let VBA refer to the cell...

Just a thought,
Corticus
 

Ivan F Moala

MrExcel MVP
Joined
Feb 10, 2002
Messages
4,209
On 2002-09-06 12:05, 2077delta wrote:
Is there a similar function in VBA to Excel's CODE function. I'm importing an ASCII file and it has some unusual characters. What I want to do is identify their Character number and based on that number direct the macro to perform the requiste procedures.


<pre/>
MsgBox Asc(ActiveCell.Value)
</pre>
 

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
This is a macro I use, it has two options; as an application, you enter the character in a fixed cell and press the form button or the current selection is used in the other. Each code only works with one character or only the first character is returned. JSW

Sub myASC()
'This code block for a cell.
If IsEmpty([B6].Value) = True Then
MsgBox "The ""Box"" is: Empty!"
Else
MsgBox "The ""ASC"" code," & Chr(13) & "for the character" & _
Chr(13) & "you entered is: " & Chr(13) & Chr(13) & _
" " & Asc([B6].Value)
'This code block for a selection.
'If IsEmpty(ActiveCell.Value) = True Then
'MsgBox "The ""Box"" is: Empty!"
'Else
'MsgBox "The ""ASC"" code," & Chr(13) & "for the character" & _
'Chr(13) & "you entered is: " & Chr(13) & Chr(13) & _
'" " & ASC(ActiveCell.Value)
End If
End Sub

P.S. This code turns out to be the same as Ivan's.
This message was edited by Joe Was on 2002-09-06 12:54
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,416
Messages
5,837,119
Members
430,477
Latest member
roseinsydney

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top