Inserting Non-Standard Symbols with VBA

flipdazed

New Member
Joined
Sep 5, 2011
Messages
25
Hi there,

I'm regularly using your fantastic site but this is the first time I've actually found a problem you didn't already have an answer for!

I want VBA to assign:

=AB24&" ≤ X ≥ "&AB25

to Cell AC25 so that it outputs:

<TABLE style="WIDTH: 62pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=83><COLGROUP><COL style="WIDTH: 62pt; mso-width-source: userset; mso-width-alt: 3035" width=83><TBODY><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: #c4d79b; WIDTH: 62pt; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl63 height=20 width=83>12 ≤ X ≥ 24</TD></TR></TBODY></TABLE>

Now when I try to use VBA it just comes out as:

<TABLE style="WIDTH: 62pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=83><COLGROUP><COL style="WIDTH: 62pt; mso-width-source: userset; mso-width-alt: 3035" width=83><TBODY><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: #c4d79b; WIDTH: 62pt; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl65 height=20 width=83>12 = X = 24</TD></TR></TBODY></TABLE>

The VBA code I'm using is:

Range("AC25").Select
ActiveCell.FormulaR1C1 = "=R[-1]C[-1]&"" < X > ""&RC[-1]"


Anyone able to help with this?

Cheers,
Alex.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Ah, apologies!

I forgot to mention the code I entered is a temporary fix:

It outputs < and > symbols but it isn't mathematically correct.

I need it to output "greater than or equal to" / "less than or equal to" symbols instead so the code itself doesn't need debugging it needs modifying.
 
Upvote 0
That problem is similar but not quite the same...

I need the symbol to come out as the product of a Visual Basic macro.

The closest thread I've found to solving my problem is:
http://www.mrexcel.com/forum/showthread.php?t=402230

However, my coding skills are basic at best and I can't find a way of embedding his code into my own... The solution to their problem came out of the piece of code below:

Code:
Dim fmt As String, s As String
  s = """ " & ChrW(8805) & " """
  fmt = s & "0.00;" & s & "-0.00;" & s & "0.00"
  Selection.NumberFormat = fmt

I figure that the ChrW(8805) is the critical bit of code for my solution but I don't know how to insert it into my own code and keep getting errors :(
 
Upvote 0
Hi
Welcome to the board

You can use the Unicode codes for the characters "greater than or equal to" / "less than or equal to" that are hex 2264 and 2265 (check the map)

Try:

Code:
Range("AC25").FormulaR1C1 = "=R[-1]C[-1]&"" " & ChrW(&H2264) & " X " & ChrW(&H2265) & """&RC[-1]"

Remark: you don't usually select objects in vba. It's unnecessary and inefficient.
 
Upvote 0
Try this or something similar

CHAR(163)&" "&CHAR(67)&" "&CHAR(179)

You have to set the cell format to Symbol though otherwise you will get garbage - I have not found the symbols anywhere else but I am sure they are there! Character 67 is "X" in Symbol but "C" in most normal fonts so dont get confused but

CHAR(163)&" C "&CHAR(179)

Will also work!

The greater than or equal to sign is also in teh unicode character set so if you know how to use that in VBA you could use that too
 
Upvote 0
Hi PGC,

Thanks ever so much! That works perfectly!

Also didn't realise I didn't need to select things!

Problem Solved.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,749
Members
452,940
Latest member
rootytrip

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