ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   adding bold to formula cell (https://www.excelbanter.com/excel-programming/413075-adding-bold-formula-cell.html)

mwam423

adding bold to formula cell
 
greetings, have cell, say A4, which forms a statement by pulling values from
two different cells, e.g., ="On "&A1&", please "&A2&" funds for a margin
call."

A1 contains a datevalue; A2 contains text, either "deliver", or "receive".
how can i have the information in A1 and A2 show as boldface in my statement
cell?

Bob Phillips

adding bold to formula cell
 
Select A4, Ctrl-B

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"mwam423" wrote in message
...
greetings, have cell, say A4, which forms a statement by pulling values
from
two different cells, e.g., ="On "&A1&", please "&A2&" funds for a margin
call."

A1 contains a datevalue; A2 contains text, either "deliver", or "receive".
how can i have the information in A1 and A2 show as boldface in my
statement
cell?




RyanH

adding bold to formula cell
 
Range("A1:A2").Font.Bold = True

Ryan

"mwam423" wrote:

greetings, have cell, say A4, which forms a statement by pulling values from
two different cells, e.g., ="On "&A1&", please "&A2&" funds for a margin
call."

A1 contains a datevalue; A2 contains text, either "deliver", or "receive".
how can i have the information in A1 and A2 show as boldface in my statement
cell?


mwam423

adding bold to formula cell
 
hi bob, i would like just the information from those cells in bold, the other
words in A4 i'd like without boldface

"Bob Phillips" wrote:

Select A4, Ctrl-B



mwam423

adding bold to formula cell
 
hi ryan, appreciate the quick reply, however, i haven't done good job of
describing what i need. in A4 which returns a sentence i'd like only the
date from A1 and single word in A2 in boldface, other words would not be in
bold.

"RyanH" wrote:

Range("A1:A2").Font.Bold = True



Dave Peterson

adding bold to formula cell
 
Formulas don't support this kind of formatting.

mwam423 wrote:

greetings, have cell, say A4, which forms a statement by pulling values from
two different cells, e.g., ="On "&A1&", please "&A2&" funds for a margin
call."

A1 contains a datevalue; A2 contains text, either "deliver", or "receive".
how can i have the information in A1 and A2 show as boldface in my statement
cell?


--

Dave Peterson

Ron Rosenfeld

adding bold to formula cell
 
On Tue, 24 Jun 2008 10:21:05 -0700, mwam423
wrote:

greetings, have cell, say A4, which forms a statement by pulling values from
two different cells, e.g., ="On "&A1&", please "&A2&" funds for a margin
call."

A1 contains a datevalue; A2 contains text, either "deliver", or "receive".
how can i have the information in A1 and A2 show as boldface in my statement
cell?


You cannot do that directly. In Excel, you can only differentially bold text
strings -- not the results of formulas.

The Sub below demonstrates how to do this. It could be shortened, but I wanted
to show all the steps:

================================
Option Explicit
Sub BoldA1A2()
Dim s As String, sA1 As String, sA2 As String
Const s1 As String = "On "
Const s2 As String = ", please "
Const s3 As String = " funds for a margin call."

sA1 = Range("A1").Text
sA2 = Range("A2").Text

With Range("A4")
.Value = s1 & sA1 & s2 & sA2 & s3
.Characters(1 + Len(s1), Len(sA1)).Font.Bold = True
.Characters(1 + Len(s1) + Len(sA1) + Len(s2), Len(sA2)).Font.Bold = True
End With
End Sub
================================
--ron

mwam423

adding bold to formula cell
 
hi dave, hope you're well. any code you can provide would be greatly
appreciated.

"Dave Peterson" wrote:

Formulas don't support this kind of formatting.



Gord Dibben

adding bold to formula cell
 
You cannot Bold just the Date from A1 and text from A2 using a formula.

Private Sub boldem()
With ActiveSheet.Range("A4")
.Value = "On " & Range("A1").Value & " please " & Range("A2").Value _
& " funds for a margin call."
With .Characters(Start:=4, Length:=Len(Range("A1").Value)).Font
.FontStyle = "Bold"
End With
With .Characters(Start:=Len(Range("A1").Value) + 12, _
Length:=Len(Range("A2").Value)).Font
.FontStyle = "Bold"
End With
End With
End Sub

Assumes shortdate format of dd/MMM/yy or similar length


Gord Dibben MS Excel MVP


On Tue, 24 Jun 2008 10:21:05 -0700, mwam423
wrote:

greetings, have cell, say A4, which forms a statement by pulling values from
two different cells, e.g., ="On "&A1&", please "&A2&" funds for a margin
call."

A1 contains a datevalue; A2 contains text, either "deliver", or "receive".
how can i have the information in A1 and A2 show as boldface in my statement
cell?



Dave Peterson

adding bold to formula cell
 
You could convert the formula to a value and do the formatting.

But you can't do this kind of formatting (manually or in code) and keep the
formula.

mwam423 wrote:

hi dave, hope you're well. any code you can provide would be greatly
appreciated.

"Dave Peterson" wrote:

Formulas don't support this kind of formatting.


--

Dave Peterson

RyanH

adding bold to formula cell
 
Oops! You are right, I did misunderstand. You can try this.

Dim myRangeA1 As String
Dim myRangeA2 As String

myRangeA1 = Range("A1")
myRangeA2 = Range("A2")

With Range("A4")
.Value = "On " & myRangeA1 & ", please " & myRangeA2 & " funds for a
margin call."
.Characters(4, Len(myRangeA1)).Font.Bold = True
.Characters(13 + Len(myRangeA1), Len(myRangeA2)).Font.Bold = True
End With

End Sub

Ryan

"mwam423" wrote:

hi ryan, appreciate the quick reply, however, i haven't done good job of
describing what i need. in A4 which returns a sentence i'd like only the
date from A1 and single word in A2 in boldface, other words would not be in
bold.

"RyanH" wrote:

Range("A1:A2").Font.Bold = True



mwam423

adding bold to formula cell
 
hi dave, yes i would lose the formula. the code provided by ryan and ron get
the result i need, thanks!

"Dave Peterson" wrote:

You could convert the formula to a value and do the formatting.

But you can't do this kind of formatting (manually or in code) and keep the
formula.



mwam423

adding bold to formula cell
 

thanks ron, like this as it looks like it can accommodate changes in
verbage, much appreciated!

Ron Rosenfeld

adding bold to formula cell
 
On Tue, 24 Jun 2008 16:05:01 -0700, mwam423
wrote:


thanks ron, like this as it looks like it can accommodate changes in
verbage, much appreciated!


Glad to help. Thanks for the feedback.
--ron


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

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