Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Bolding middle of a field programmatically

Is there a way to programatically tell part of a cell to be bold. For
example, I have a cell that says:

Your library book is OVERDUE. If you do not bring it back by MM/DD/YY, you
will be charged $$.$$.

I want the words OVERDUE, MM/DD/YY and $$.$$ bolded. What I am hoping for
is code to add before after the words for exampe <BOVERDUE</B.

Does such a thing exist in excel?

Thanks for any help.

Robs
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Bolding middle of a field programmatically

Robs wrote:
Is there a way to programatically tell part of a cell to be bold. For
example, I have a cell that says:

Your library book is OVERDUE. If you do not bring it back by MM/DD/YY, you
will be charged $$.$$.

I want the words OVERDUE, MM/DD/YY and $$.$$ bolded. What I am hoping for
is code to add before after the words for exampe <BOVERDUE</B.

Does such a thing exist in excel?

Thanks for any help.

Robs


Range("g7").Characters(Start:=5, Length:=3).Font.FontStyle = "Bold"


Change start and length and "g7" to your values.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Bolding middle of a field programmatically


Hello Robs,

Here is an example using cell "A1"...

AmountDue = "$1.75"
A1 = "Your library book is OVERDUE 01/22/06" & AmoutDue
Range("A1").Characters(22, 16 + Len(AmountDue)).Font.Bold = True

The Characters property has 2 arguments, the starting character
position and the number of characters. Since the amount can vary in
length, I placed it in a separate formatted string.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=505843

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Bolding middle of a field programmatically

Leith:

I tried what you said, it does not work. so I tried to simplfy what I
was doing and build from there. So I made cell (B1) have the word TEST in
it. Then in cell A11, I put the following formula:
=Range("B1").Characters(1,Len(B1)).Font.Bold = true. I get the error
message: Your formula contains an error.

I have to admit, I am not an excel programmer. I do most of my
programming in C#.

Thanks for any help that you have.

Robs

"Leith Ross" wrote:


Hello Robs,

Here is an example using cell "A1"...

AmountDue = "$1.75"
A1 = "Your library book is OVERDUE 01/22/06" & AmoutDue
Range("A1").Characters(22, 16 + Len(AmountDue)).Font.Bold = True

The Characters property has 2 arguments, the starting character
position and the number of characters. Since the amount can vary in
length, I placed it in a separate formatted string.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=505843


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Bolding middle of a field programmatically

See my answer for insights into your problem.
You can not achieve this with a formula.

--
Regards,
Tom Ogilvy


"Robs" wrote in message
...
Leith:

I tried what you said, it does not work. so I tried to simplfy what I
was doing and build from there. So I made cell (B1) have the word TEST in
it. Then in cell A11, I put the following formula:
=Range("B1").Characters(1,Len(B1)).Font.Bold = true. I get the error
message: Your formula contains an error.

I have to admit, I am not an excel programmer. I do most of my
programming in C#.

Thanks for any help that you have.

Robs

"Leith Ross" wrote:


Hello Robs,

Here is an example using cell "A1"...

AmountDue = "$1.75"
A1 = "Your library book is OVERDUE 01/22/06" & AmoutDue
Range("A1").Characters(22, 16 + Len(AmountDue)).Font.Bold = True

The Characters property has 2 arguments, the starting character
position and the number of characters. Since the amount can vary in
length, I placed it in a separate formatted string.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:

http://www.excelforum.com/member.php...o&userid=18465
View this thread:

http://www.excelforum.com/showthread...hreadid=505843






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Bolding middle of a field programmatically

Sub AAA()
Dim Amountdue As Single
Dim DueDate As Date
Dim iloc1 As Long, iloc2 As Long
Dim iloc3 As Long
Amountdue = 1.75
DueDate = DateValue("1/23/2006")
s = "Your library book is OVERDUE. " & _
"If you do not bring it back by MM/DD/YY," & _
" you will be charged " & Format(Amountdue, _
"$ #,##0.00") & "."
s = Replace(s, "MM/DD/YY", _
Format(DueDate + 7, "MM/DD/YY"))
Range("A1").Value = s
Range("A1").Font.Bold = False
iloc2 = InStr(1, s, "by ", vbTextCompare)
Range("A1").Characters(iloc2 + 3, 8). _
Font.Bold = True
iloc3 = InStr(1, s, "$", vbTextCompare)
Range("A1").Characters(iloc3, _
Len(s) - iloc3).Font.Bold = True
iloc1 = InStr(1, s, "OVERDUE", _
vbTextCompare)
Range("A1").Characters(iloc1, 7).Font.Bold = True
End Sub

Note that you can not do rich text formatting on a cell that contains a
formula.

--
Regards,
Tom Ogilvy


"Robs" wrote in message
...
Is there a way to programatically tell part of a cell to be bold. For
example, I have a cell that says:

Your library book is OVERDUE. If you do not bring it back by MM/DD/YY,

you
will be charged $$.$$.

I want the words OVERDUE, MM/DD/YY and $$.$$ bolded. What I am hoping for
is code to add before after the words for exampe <BOVERDUE</B.

Does such a thing exist in excel?

Thanks for any help.

Robs



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
Programmatically reading data field values from PivotTable Enrico Campidoglio[_2_] Excel Programming 2 July 13th 05 12:32 PM
Bolding Row from VB6 Ian B[_2_] Excel Programming 4 July 9th 05 11:19 PM
Bolding when subtotalling mrsteve1 Excel Worksheet Functions 2 February 17th 05 11:26 PM
Bolding Dale[_12_] Excel Programming 2 September 30th 04 04:21 PM
Bolding specific text Scot Rundell Excel Programming 2 September 15th 03 07:20 AM


All times are GMT +1. The time now is 01:31 PM.

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"