Adding a micron symbol to text string

S

Stopher

Hi All,

How do i add a symbol to text string?

I have something like:

Text_String = " Text" & Variable & " um"

but what i want is the u in the um above to be the micron symbol
(.font = "Symbol") on m

I was thinking something like:

Text_String = " Text" & Variable & len("m").font = "Symbol" & "m"

or something like that, with formating the m in the text string
itself.

Any ideas?

Stopher
 
B

Barb Reinhardt

How about something like this?

Sub testing()
Dim lastChars As String
myValue = 12345

ActiveCell.Value = "Text String " & myValue & " mm"
'Assume that mm are the last character
lastChars = Right(ActiveCell.Value, 2)
Debug.Print lastChar
If lastChars = "mm" Then
With ActiveCell.Characters(Start:=Len(ActiveCell.Value) - 1,
Length:=1).Font
.Name = "Symbol"
.FontStyle = "Regular"
.Size = 12
End With
End If
End Sub

HTH,
Barb Reinhardt
 
O

OssieMac

Hi Stopher,

Try this and see if it does what you want:-

Sub Font_Mix()

Dim strTest As String 'String with all characters
Dim umPosition As Single 'Position where um starts

strTest = "Testum"

'Find start position of characters um
umPosition = InStr(1, strTest, "um")

'Assign string to a cell
'NOTE: the font code below does not work with a variable
Range("A1") = strTest

'Change font on 1 character starting at position umPosition
With Range("A1").Characters(Start:=umPosition, Length:=1).Font
.Subscript = True
End With

End Sub

regards,

OssieMac
 
O

OssieMac

Since viewing Barb Reinhardt's reply I now believe that I mis-interpreted
what you wanted to do. Barb's reply is the correct one.

Regards,

OssieMac
 
S

Stopher

Since viewing Barb Reinhardt's reply I now believe that I mis-interpreted
what you wanted to do. Barb's reply is the correct one.

Regards,

OssieMac













- Show quoted text -

Thnx for the replies, but am really trying to do this in VB without
cell references, so having a function in a text string that will
format one or more letter to a different font.

Stopher
 
B

Barb Reinhardt

I'm not sure what you mean by "do this in VB without cell references". You
have to have cell references somehow so that it knows what to format.

What did you have in mind?

FYI, the convention in this newgroup is to top post. Threads get very messy
when there is top and bottom posting. I'm guessing you're using a
newsreader that defaults to bottom posting.

Barb Reinhardt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top