Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Using Excel Programming to bold part of the text

I would like to create the information below where the TEXT function result is
bold and the latter text is a normal font; see below. One person in the Excel
Function Newsgroup suggested that this could be done using Excel Programming.
=TEXT(G16*100,"00")&" cents $US"

Any sugestions will be much appreciated.

Roger
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Using Excel Programming to bold part of the text

The only way to make this change automatically would be to use a
Worksheet_Change event macro. The following routine searches for the 1st space
and makes everything to the left of that space bold. That said, if I type text
in the cell, like 23 cents $US, it works. But with 0.23 in G1, it doesn't work
with your formula.


Private Sub Worksheet_Change(ByVal Target As Range)
Dim Txt As String
Dim i As Long

Txt = Target.Text
i = InStr(Txt, " ")
Target.Characters(1, i - 1).Font.Bold = True

End Sub


On Wed, 20 Oct 2004 03:51:33 GMT, (Roger Bedford) wrote:

I would like to create the information below where the TEXT function result

is
bold and the latter text is a normal font; see below. One person in the

Excel
Function Newsgroup suggested that this could be done using Excel Programming.
=TEXT(G16*100,"00")&" cents $US"

Any sugestions will be much appreciated.

Roger


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 733
Default Using Excel Programming to bold part of the text

"Myrna Larson" wrote...
The only way to make this change automatically would be to use a
Worksheet_Change event macro. The following routine searches for the
1st space and makes everything to the left of that space bold. That
said, if I type text in the cell, like 23 cents $US, it works. But
with 0.23 in G1, it doesn't work with your formula.


It shouldn't work with any formula.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Txt As String
Dim i As Long

Txt = Target.Text
i = InStr(Txt, " ")
Target.Characters(1, i - 1).Font.Bold = True
End Sub

(Roger Bedford) wrote:

....
=TEXT(G16*100,"00")&" cents $US"


If the cell in question contains a formula, the cell doesn't contain a
Characters object that can be used to provide substring formatting. For
example, under Excel 2000, Myrna's event handler makes the ENTIRE result of
Roger's formula bold.

Doesn't the Characters object only work with substrings only when cells
contain text constants?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Using Excel Programming to bold part of the text

Hi Roger,

As Harlan says a font in a formula cell cannot have mixed formats.

One approach would be NOT to write a formula in the cell where you want your
cents to be displayed, and let the following Event code do it for you, along
the lines of Myrna's suggestion.

Select G1 and in the Name box left of input bar type "centsIn" without
quotes. Select the cell where you want the converted cents to be displayed
and name it "centsOut".

Right click the sheet tab View code and paste following into the module:


Private Sub Worksheet_Change(ByVal Target As Range)
Dim rIn As Range, rOut As Range, n As Long, s As String

On Error GoTo errH
Set rIn = Range("centsIn")

If Intersect(Target, rIn) Is Nothing Then Exit Sub
Set rOut = Range("centsOut")
If IsNumeric(rIn) Then
s = rIn.Value * 100
Else: s = "error"
End If
n = Len(s)
s = s & " cents US$"
Application.EnableEvents = False
With rOut
.Font.Bold = False
.Value = s
.Characters(1, n).Font.Bold = True
End With
done:
Application.EnableEvents = True
Exit Sub
errH:
s = ""
If rIn Is Nothing Then s = "centsIn"
If rOut Is Nothing Then s = "centsOut"
If s < "" Then MsgBox s & " does not exist"
GoTo done
End Sub


The reason for naming the cells is the code should work if subsequently you
move them.

Regards,
Peter

"Roger Bedford" wrote in message
...
I would like to create the information below where the TEXT function

result is
bold and the latter text is a normal font; see below. One person in the

Excel
Function Newsgroup suggested that this could be done using Excel

Programming.
=TEXT(G16*100,"00")&" cents $US"

Any sugestions will be much appreciated.

Roger



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Using Excel Programming to bold part of the text

A non-programmatic approach would be to put the TEXT() formula in one
cell and the "cents $US" literal in the cell to the right. Right-align
the former and left-align the latter. Now, make the entire first cell
bold.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I would like to create the information below where the TEXT function result is
bold and the latter text is a normal font; see below. One person in the Excel
Function Newsgroup suggested that this could be done using Excel Programming.
=TEXT(G16*100,"00")&" cents $US"

Any sugestions will be much appreciated.

Roger



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Using Excel Programming to bold part of the text

Thank you all very much for your help. I have decided to abort solving
this problem as it looks almost impossible to do in a clean manner and I
am only used to Excel 5 macros so have a long way to go to get up to the
new macros.

Again, many thanks,

Roger



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bold part of combined cell Adrien Excel Worksheet Functions 4 October 30th 08 01:58 PM
Format Bold - Only Part of a Function [email protected] Excel Worksheet Functions 3 August 12th 08 10:30 PM
un-Bold part of text in a cell (automatically) chris Excel Discussion (Misc queries) 2 September 26th 07 10:21 PM
Join bold and non-bold text in one cell bkincaid Excel Discussion (Misc queries) 3 March 21st 06 12:58 AM
Bold part of formula results Rita Palazzi Excel Discussion (Misc queries) 4 December 16th 04 07:51 PM


All times are GMT +1. The time now is 11:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"