Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Programmatically reading data field values from PivotTable | Excel Programming | |||
Bolding Row from VB6 | Excel Programming | |||
Bolding when subtotalling | Excel Worksheet Functions | |||
Bolding | Excel Programming | |||
Bolding specific text | Excel Programming |