简体   繁体   中英

VBA Macro Excel: How to read a Unicode character from Excel cell

I am struggling to read a Unicode character back from a cell in VBA Excel.

Sub mySub()
    Cells(1, "A").Value = ChrW(10003)   ' Writes checkbox symbol to A1

    MsgBox Asc(Cells(1, "A").Value)     ' Output:  63 (questionmark symbol)
                                        ' Expected Output: 10003
End Sub

I need to read the Unicode character to see, if the checkbox symbol was modified by a user. I have no Idea how to compare a Unicode character with the cells value..

Sometimes all you need is second pair of eyes. :)

Sub mySub()
    Cells(1, "A").Value = ChrW(10004)   ' Writes checkbox symbol to A1

    'MsgBox Asc(Cells(1, "A").Value)     ' Output:  63 (questionmark symbol)
                                   ' Expected Output: 10003
    '/ Works! 
    MsgBox AscW(Cells(1, "A").Value2)    'Almost there. Use AscW instead of Asc
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM