PC Review


Reply
Thread Tools Rate Thread

Adding a micron symbol to text string

 
 
Stopher
Guest
Posts: n/a
 
      22nd Aug 2007
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      22nd Aug 2007
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
>
>

 
Reply With Quote
 
=?Utf-8?B?T3NzaWVNYWM=?=
Guest
Posts: n/a
 
      22nd Aug 2007
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
>
>

 
Reply With Quote
 
=?Utf-8?B?T3NzaWVNYWM=?=
Guest
Posts: n/a
 
      22nd Aug 2007
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
> >
> >

 
Reply With Quote
 
Stopher
Guest
Posts: n/a
 
      22nd Aug 2007
On Aug 22, 12:10 pm, OssieMac <Ossie...@discussions.microsoft.com>
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

 
Reply With Quote
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      22nd Aug 2007
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 <Ossie...@discussions.microsoft.com>
> 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
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding text string to cells Ray W. Microsoft Excel New Users 2 28th Mar 2008 02:33 PM
Re: Adding Text to a String Debra Dalgleish Microsoft Excel Misc 0 29th Nov 2006 05:34 AM
Adding the Trademark symbol to text =?Utf-8?B?Q2hyaXNK?= Microsoft Frontpage 14 11th Nov 2004 12:01 PM
adding a space to a text string Brian.anderson@ericsson.com Microsoft Excel Worksheet Functions 1 19th Feb 2004 05:06 PM
Re: Adding character to text string JMay Microsoft Excel Worksheet Functions 0 25th Sep 2003 08:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:47 AM.