View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Tushar Mehta Tushar Mehta is offline
external usenet poster
 
Posts: 1,071
Default Placing triangle symbols WITHIN cell for significance testing

To toggle between unicode characters and hex using ALT+x, use
Sub setAltX()
Application.OnKey "%x", "toggleUnicode"
End Sub
Sub resetAltX()
Application.OnKey "%x"
End Sub
Sub toggleUnicode()
If Len(ActiveCell.Value) 1 Then
ActiveCell.Value = ChrW("&H" & ActiveCell.Value)
Else
ActiveCell.Value = Hex(AscW(ActiveCell.Value))
End If
End Sub

Run the first to enable the toggle capability. Then, select any cell
with a hex code in it and use ALT+x. Finally, to disable the toggle,
run the 2nd subroutine. Do keep in mind that XL will not run a macro
while in edit mode. That might reduce the value of the above
capability.

To toggle between unicode and decimal, use
Sub toggleUnicodeDec()
If Application.WorksheetFunction.IsNumber(ActiveCell. Value) Then
ActiveCell.Value = ChrW(ActiveCell.Value)
Else
ActiveCell.Value = AscW(ActiveCell.Value)
End If
End Sub

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Hi Stephen,

Thanx a lot for the help.

The following chrw codes in VBA worked great for me.

? 9650
? 9658
? 9660
? 9668


I was just wondering. The help file for "Insert a symbol" in excel XP says
within --Unicode options- "If you know the character code for a Unicode
character, you do not need to open the Symbol dialog box. Type the Unicode
hexadecimal character code in the document, and then press ALT+X. "

In the above why are they referring to a document as in "Type unicode....in
the document"? Shouldnt they say excel sheet?

I went to an excel sheet and typed 25BC and pressed Alt +X , but nothing
happened? Am I supposed to type this somewhere else. (I also tried with an
equal sign -- = 25BC -- but to no avail)

The "regular" worksheet function is, at least in my Excel 2003 version,
not unicode enabled, and will only accept values 1 to 255. IMHO your way
to go:

In my excel EVEN 1 to 255 gives a name error. I thought that may be charw is
not available as a function within workbook environment and may be available
in VBA only. But you say that 1 to 255 is working fine in worksheet, so i
guess I am wrong.

Regards,
Hari
India

"Dr. Stephan Kassanke" wrote in message
...

"Hari Prasadh" schrieb im
Newsbeitrag ...
Hi,

I want to insert symbols (Arial font) 25BC, 25B2, 25C4 and 25BA from
Unicode (hex) -- Their descriptions are Black down-pointing
triangle/up-pointing triangle/left-pointing and right pointing triangle.

I tried code(1) to code(255) but none of them yielded the triangles I
require. I want to do this using a programmatic approach.

Is it possible and if yes, please guide me.

Thanks a lot,
Hari
India

PS: - I would be running some formulas for comparing cells across 2
columns (Z-test) and based on the result (True or false) would like to
place one of these symbols in the third column of the same row. then
using R Bovey's chart labeler show the significances in my charts.


You are trying to insert unicode symbols which are not included in ASCII
code, thus chr() will fail. Try the ChrW function which will yield unicode
strings. Convert your hex values to decimals and try

range("a1")= chrw(9660) will result in the triangle downwards in cell A1.

The "regular" worksheet function is, at least in my Excel 2003 version,
not unicode enabled, and will only accept values 1 to 255. IMHO your way
to go: a loop in VBA checking your conditions for each cell and inserting
the appropriate symbol via the chrw function.

cheers
Stephan