如何使用 Excel vba 引用特殊字符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21377275/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Reference Special Characters Using Excel vba
提问by parap
I have several special characters in an excel spreadsheet. How do I reference them in Excel VBA?
我在 Excel 电子表格中有几个特殊字符。如何在 Excel VBA 中引用它们?
The characters I need are not in the standard 255 ASCII codes.
我需要的字符不在标准的 255 ASCII 代码中。
I was thinking perhaps Chr(code)
would work, but I'm not able to find the codes for the characters I need to test this.
我在想也许Chr(code)
会奏效,但我找不到我需要测试的字符的代码。
回答by ttaaoossuu
User ChrW()
instead of Chr()
function to reference Unicode characters:
用户ChrW()
而不是Chr()
函数来引用 Unicode 字符:
ChrW(23383)
will produce 字
.
ChrW(23383)
会产生字
.
Chr(23383)
will throw an exception.
Chr(23383)
会抛出异常。
回答by Teodora
Use this script to see ChrW characters in F column
使用此脚本查看 F 列中的 ChrW 字符
Sub caracter()
Dim caract As String
Dim r As Range
Dim i As Integer
caract = ChrW(633)
For i = 1 To 20000
caract = ChrW(i)
ActiveSheet.Cells(i, 6).Value = caract
Next i
End Sub