Concatenate formula or &
One way:
Put this in your worksheet code module (right-click on the worksheet tab
and choose View Code):
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rSource As Range
Dim i As Long
Dim nPos As Long
Dim nLen As Long
Dim sTemp As String
Set rSource = Range("A1:F1")
If Not Intersect(Target, rSource) Is Nothing Then
For i = 1 To rSource.Cells.Count
sTemp = sTemp & " " & rSource(i).Text
Next i
With Range("A2")
On Error Resume Next
Application.EnableEvents = False
.Value = Mid(sTemp, 2)
Application.EnableEvents = True
On Error Resume Next
nPos = 1
For i = 1 To rSource.Count
nLen = Len(rSource(i).Text)
With .Characters(nPos, nLen).Font
.ColorIndex = rSource(i).Font.ColorIndex
.Bold = rSource(i).Bold
End With
nPos = nPos + nLen + 1
Next i
End With
End If
End Sub
In article ,
Sam wrote:
what should i do to format a cell that has formula...?
can i change this cell content to a text format after i Concatenate?
my main goal is to automate an analysis sentence that contains percentage
and increase or decrease in it including their formats. do you know how
should i do it
"Dave Peterson" wrote:
Cells with formulas don't support this kind of formatting.
Sam wrote:
Thanks alot.
now i have another problem, how can i keep the formatting of A1 or any
cell. for example if A1 is a bold red number with a comma in a
middle(<red<b5,333</b</red how can i keep the same format when i use
Concatenate?
"Dave F" wrote:
=concatenate(A1," ",B1," ",C1," ",D1," ",round((E1*100),0)," ",F1)
Dave
--
Brevity is the soul of wit.
"Sam" wrote:
I am creating a text template in excel and I have the following 2
rows(combination of text, number and formula and %). please note that
I
changed the format of E1 to percentage with 2 decimal.
To combine the following cells together:
A1 | B1 | C1| D1 | E1 | F1
2 | Divided by | 3 | is | =(A1/C1) | percent
i created this formula in cell A2:
=A1&B1&C1&D1&E1&F1
and i get:
2 Divided by 3 is: .666666666666 percent
and i want to get the following in one cell:
2 Divided by 3 is: 66.66% percent
what should i do?
--
Dave Peterson
|