adding bold to formula cell

  • Thread starter Thread starter mwam423
  • Start date Start date
M

mwam423

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?
 
Select A4, Ctrl-B

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
hi bob, i would like just the information from those cells in bold, the other
words in A4 i'd like without boldface
 
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.
 
Formulas don't support this kind of formatting.
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?
 
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
 
hi dave, hope you're well. any code you can provide would be greatly
appreciated.
 
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
 
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.
 
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
 
hi dave, yes i would lose the formula. the code provided by ryan and ron get
the result i need, thanks!
 
thanks ron, like this as it looks like it can accommodate changes in
verbage, much appreciated!
 
thanks ron, like this as it looks like it can accommodate changes in
verbage, much appreciated!

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top