Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Bold items within text string

Hi All,

I found a bit of code on the newsgroup that bolds the text within a
cell during a concatenation of several cells:
Sub BoldNotesTitle()

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

I'm trying to take this concept and apply it to a range. I wrote a
formula (below) that does the concatenation I need. Somehow I need to
take my formula into code and BOLD the cells J$1, K$1, L$1, M$1, N$1.
My biggest question is how to I apply this formula to the range
H2:H500? Thanks!

=IF(ISBLANK(J2),"",J$1&" - "&J2&CHAR(10))&IF(ISBLANK(K2),"",K$1&" -
"&K2&CHAR(10))&IF(ISBLANK(L2),"",L$1&" -
"&L2&CHAR(10))&IF(ISBLANK(M2),"",M$1&" -
"&M2&CHAR(10))&IF(ISBLANK(N2),"",N$1&" - "&N2&CHAR(10))
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Bold items within text string

Somehow I need to take my formula into code
and BOLD the cells J$1, K$1, L$1, M$1, N$1.


You cannot bold parts of text output by a formula... its either bold all the
displayed text or not. You can only bold parts of the text in a cell if that
text is a text constant.

Rick Rothstein (MVP - Excel)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Bold items within text string

Thanks Rick. How about this - since the parts of the text string I
want bolded are constant (ie, column headers J$1:N$1), can I read the
column headers in variables, and do a FIND routine to find each column
header in the text string and then bold?

On Jun 9, 10:56*am, "Rick Rothstein"
wrote:
Somehow I need to take my formula into code
and BOLD the cells J$1, K$1, L$1, M$1, N$1.


You cannot bold parts of text output by a formula... its either bold all the
displayed text or not. You can only bold parts of the text in a cell if that
text is a text constant.

Rick Rothstein (MVP - Excel)


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Bold items within text string

Thanks Rick. How about this - since the parts of the text string I
want bolded are constant (ie, column headers J$1:N$1), can I read
the column headers in variables, and do a FIND routine to find
each column header in the text string and then bold?


You cannot bold individual parts or text generated by a formula... there is
no way around that using formulas. If you were willing to turn the
calculating of the formula to VB in a Change event procedure, then you could
have that procedure inject pure text into the cell and that text, being a
constant, could be bolded in parts.

Rick Rothstein (MVP - Excel)

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Bold items within text string

Thanks Rick. I'm certainly willing, but have no idea how to do that!

On Jun 9, 11:36*am, "Rick Rothstein"
wrote:
Thanks Rick. *How about this - since the parts of the text string I
want bolded are constant (ie, column headers J$1:N$1), can I read
the column headers in variables, and do a FIND routine to find
each column header in the text string and then bold?


You cannot bold individual parts or text generated by a formula... there is
no way around that using formulas. If you were willing to turn the
calculating of the formula to VB in a Change event procedure, then you could
have that procedure inject pure text into the cell and that text, being a
constant, could be bolded in parts.

Rick Rothstein (MVP - Excel)




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Bold items within text string

Rick,

I created a formula in a cell to do what I wanted, then hard-coded the
entire column. Now I have a column of values, with no formulas. I
tried to do a simple Replace (ie find Bob and replace with Bob in
bold), but found that when it finds the text string I'm trying to
replace, it adjusts all contents of the cell.

On Jun 9, 11:49*am, Steve wrote:
Thanks Rick. *I'm certainly willing, but have no idea how to do that!

On Jun 9, 11:36*am, "Rick Rothstein"



wrote:
Thanks Rick. *How about this - since the parts of the text string I
want bolded are constant (ie, column headers J$1:N$1), can I read
the column headers in variables, and do a FIND routine to find
each column header in the text string and then bold?


You cannot bold individual parts or text generated by a formula... there is
no way around that using formulas. If you were willing to turn the
calculating of the formula to VB in a Change event procedure, then you could
have that procedure inject pure text into the cell and that text, being a
constant, could be bolded in parts.


Rick Rothstein (MVP - Excel)- Hide quoted text -


- Show quoted text -


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 621
Default Bold items within text string

Your example is quite simple and I imagine you need more but here's a start.

Select your range of hard-coded cells and run this macro to bold Bob in all
cells.

Sub Bold_String()
Dim rng As Range
Dim cell As Range
Dim start_str As Integer
Set rng = Selection
For Each cell In rng
start_str = InStr(cell.Value, "Bob")
If start_str Then
cell.Characters(start_str, 3).Font.Bold = True
End If
Next
End Sub


Gord Dibben MS Excel MVP

On Thu, 9 Jun 2011 13:48:49 -0700 (PDT), Steve
wrote:

Rick,

I created a formula in a cell to do what I wanted, then hard-coded the
entire column. Now I have a column of values, with no formulas. I
tried to do a simple Replace (ie find Bob and replace with Bob in
bold), but found that when it finds the text string I'm trying to
replace, it adjusts all contents of the cell.

On Jun 9, 11:49*am, Steve wrote:
Thanks Rick. *I'm certainly willing, but have no idea how to do that!

On Jun 9, 11:36*am, "Rick Rothstein"



wrote:
Thanks Rick. *How about this - since the parts of the text string I
want bolded are constant (ie, column headers J$1:N$1), can I read
the column headers in variables, and do a FIND routine to find
each column header in the text string and then bold?


You cannot bold individual parts or text generated by a formula... there is
no way around that using formulas. If you were willing to turn the
calculating of the formula to VB in a Change event procedure, then you could
have that procedure inject pure text into the cell and that text, being a
constant, could be bolded in parts.


Rick Rothstein (MVP - Excel)- Hide quoted text -


- Show quoted text -

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Bold items within text string

Thanks Gord. Yes, reality is a bot more complicated than "Bob"! But
this is a one-time routine, so no need to get more sophisticated with
code. Thanks for your help!

On Jun 9, 3:23*pm, Gord Dibben wrote:
Your example is quite simple and I imagine you need more but here's a start.

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
search if a string contains text matching items in a list neil Excel Worksheet Functions 3 March 11th 08 09:13 PM
how to apply bold within string text dragonball20cal Excel Worksheet Functions 7 July 23rd 07 03:18 AM
auto bold partial text in a string dave in Toronto Excel Discussion (Misc queries) 1 June 12th 07 01:07 PM
Join bold and non-bold text in one cell bkincaid Excel Discussion (Misc queries) 3 March 21st 06 12:58 AM
How do I ask Excel to count how many items are in BOLD TYPE? Head Honcho Excel Discussion (Misc queries) 1 August 5th 05 12:35 AM


All times are GMT +1. The time now is 09:46 AM.

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

About Us

"It's about Microsoft Excel"