CODE Function

2077delta

Active Member
Joined
Feb 17, 2002
Messages
252
Office Version
  1. 365
Platform
  1. Windows
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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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
 
Upvote 0
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
 
Upvote 0
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>
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,216,130
Messages
6,129,058
Members
449,484
Latest member
khairianr

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
Back
Top