View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
[email protected] RJQMAN@gmail.com is offline
external usenet poster
 
Posts: 46
Default Make 1st word in cell bold after combining words from two cells

On Jun 5, 7:08*am, Ron Rosenfeld wrote:
On Wed, 4 Jun 2008 20:45:41 -0700 (PDT), "
wrote:





I am combining the words from two cells, and I would like to change
the font of the first word in the combined cell. *However, I keep
getting the font of the entire cell to change.


The cell has this formula, which draws text from two other pages in
the workbook, and it works fine


=Paragraphs!C8&" "&Details!B2


The first cell has about 60 characters in it, and the second cell
about 30 or so. *The length of the first cell never varies, but the
length of the second cell does.


OK. *So now the correct text is in the target cell. *Now I want to
make the first word bold-face. *I could not figure out how to do it
without VBA, so I tried to do this in single statement in a VBA
subroutine. *It caused the entire cell to turn bold face..


ActiveCell.Characters(Start:=1, Length:=1).Font.FontStyle = "Bold"


What can I do? *Any help is appreciated.


You can't do that in Excel with a formula in the cell. *You can only
differentially format characters in a cell if the cell contains a text string.

So you will need to execute your formula in a VBA macro; store the result in
the desired cell as a text string, and then do your differential format.

Without knowing more details, it's hard to know the best way, but something
like the following should give you some ideas as to how to approach the problem

===========================================
Option Explicit
Sub Para()
Dim rSrc1 As Range, rSrc2 As Range
Dim rDest As Range
Dim lFirstWord As Long

* * Set rSrc1 = Worksheets("Sheet2").Range("B2")
* * Set rSrc2 = Worksheets("Sheet3").Range("C8")
* * Set rDest = Worksheets("Sheet1").Range("A1")

With rDest
* * .Value = rSrc1.Value & " " & rSrc2.Value
* * lFirstWord = InStr(1, .Value, " ") - 1
* * .Characters(1, lFirstWord).Font.Bold = True
End With
End Sub
=====================================
--ron- Hide quoted text -

- Show quoted text -


RON - Thanks so much. That solved my problem! I appreciate all who
responded. Would somebody out there please write a decent book on how
to use this amazing program!? I have purchased 5 or 6 books that all
turn out to never have the information I really need. Without this
News Group, I would be lost. Thanks many times over.