View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Preserving formatting in a formula.

How about changing the values right where they sit.

Select the range and run this macro:

Option Explicit
Sub testme()
Dim myCell As Range
Dim myRng As Range
Dim myPFX As String

myPFX = "Customer: "

Set myRng = Nothing
On Error Resume Next
Set myRng = Intersect(Selection, Selection.Cells.SpecialCells(xlTextValues))
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "Select some cells with values!"
Exit Sub
End If

For Each myCell In myRng.Cells
With myCell
.Value = myPFX & .Text
With .Characters(Start:=1, Length:=Len(myPFX))
.Font.ColorIndex = 3
.Font.Bold = True
End With
End With
Next myCell

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

..colorindex = 3
is red in my workbook. It doesn't have to be that for your workbook (but
probably is).

NLiles wrote:

That would be a thought but I would have to highlight the first 10-15
characters of every cell one at a time and change the format.. I would have
to do this ~400 times... I just thought there might be an easy way to get the
formatting to carry over from one cell to the combined formula..

"Gary''s Student" wrote:

You need to copy the formulas and paste/special/value elsewhere. The result
will be a text string. You can then format individual characters
--
Gary''s Student - gsnu200723


--

Dave Peterson