![]() |
Adding a micron symbol to text string
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 |
Adding a micron symbol to text string
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 "Stopher" wrote: 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 |
Adding a micron symbol to text string
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 "Stopher" wrote: 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 |
Adding a micron symbol to text string
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 "OssieMac" wrote: 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 "Stopher" wrote: 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 |
Adding a micron symbol to text string
On Aug 22, 12:10 pm, OssieMac
wrote: 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 "OssieMac" wrote: 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 "Stopher" wrote: 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- Hide quoted text - - 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 |
Adding a micron symbol to text string
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 "Stopher" wrote: On Aug 22, 12:10 pm, OssieMac wrote: 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 "OssieMac" wrote: 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 "Stopher" wrote: 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- Hide quoted text - - 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 |
All times are GMT +1. The time now is 01:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com