CODE Function

2077delta

Board Regular
Joined
Feb 17, 2002
Messages
242
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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

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
 

Watch MrExcel Video

Forum statistics

Threads
1,129,553
Messages
5,636,989
Members
416,953
Latest member
broexc

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