ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Text Formating (https://www.excelbanter.com/excel-programming/428894-text-formating.html)

Rahul Gupta

Text Formating
 
Hello There,

I have created a Macro and i want it to return formated text to be appended
to a text.

For Eg. If my macro Return "I Love You" then i need it to be formated.

="My Response is " & <Bold<Italicsmacro Name</bold</Italics & ". Hope
you like it".

How can i do this?

Regards

Rick Rothstein

Text Formating
 
You cannot format the text itself (that is, within the code)... what you
need to do is insert the text into a cell and then apply the formatting you
want to the characters you want. Here is a code example to give you the idea
of what I mean...

Sub Test()
Dim Answer As String
Answer = InputBox("Tell me something...")
With Range("F5")
.Value = "My Response is " & Answer & ". Hope you like it."
With .Characters(16, Len(Answer)).Font
.Bold = True
.Italic = True
End With
End With
End Sub

--
Rick (MVP - Excel)


"Rahul Gupta" wrote in message
...
Hello There,

I have created a Macro and i want it to return formated text to be
appended
to a text.

For Eg. If my macro Return "I Love You" then i need it to be formated.

="My Response is " & <Bold<Italicsmacro Name</bold</Italics & ". Hope
you like it".

How can i do this?

Regards



Gord Dibben

Text Formating
 
Not too clear on what you need but maybe you can adapt this?

Sub Highlight_Word()
Dim rng As Range
Dim Cell As Range
Dim start_str As Integer
On Error GoTo endit
myword = InputBox("Enter the search string ")
If myword = "" Then Exit Sub
Mylen = Len(myword)
Set rng = Selection
With rng
.Font.FontStyle = "regular"
.Value = "My response is " & myword & ". Hope you like it"
start_str = InStr(.Value, myword)
If start_str Then
.Characters(start_str, Mylen).Font.FontStyle = "bold italic"
End If
End With
endit:
End Sub


Gord Dibben MS Excel MVP

On Sun, 24 May 2009 08:02:01 -0700, Rahul Gupta
wrote:

Hello There,

I have created a Macro and i want it to return formated text to be appended
to a text.

For Eg. If my macro Return "I Love You" then i need it to be formated.

="My Response is " & <Bold<Italicsmacro Name</bold</Italics & ". Hope
you like it".

How can i do this?

Regards




All times are GMT +1. The time now is 07:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com