Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 50
Default Format part of text in concatenated field

I have a formula in cell B2 that concatenates a combination of text &
contents from other cells in the worksheet. In the table below, cell C2
represents the color, cell D2 is the type of item, and cell E2 is the
quantity in inventory. For example:

C2 D2 E2
---- ---- ----
Blue Rug 3

The concatenation formula in cell B2 looks like this:

=C2&" "&D2&" - Qty ("&E2&")"

So that the result in B2 looks like this: Blue Rug - Qty (3)

What I would like is to format the "Qty (3)" portion of the text result to
be bold, or a different color, or italicized, or somehow highlighted to make
it stand out from the rest of the text in that cell. Is there a special
format code that I can insert right before each of the three components that
make up the " - Qty (3)" part of the text to make that happen?



  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Format part of text in concatenated field

Hi,

A cell which contains text can have a format applied to part of that text,
but that can't be done if the text contains a formula, rather than just
text.

Mike


"jday" wrote:

I have a formula in cell B2 that concatenates a combination of text &
contents from other cells in the worksheet. In the table below, cell C2
represents the color, cell D2 is the type of item, and cell E2 is the
quantity in inventory. For example:

C2 D2 E2
---- ---- ----
Blue Rug 3

The concatenation formula in cell B2 looks like this:

=C2&" "&D2&" - Qty ("&E2&")"

So that the result in B2 looks like this: Blue Rug - Qty (3)

What I would like is to format the "Qty (3)" portion of the text result to
be bold, or a different color, or italicized, or somehow highlighted to make
it stand out from the rest of the text in that cell. Is there a special
format code that I can insert right before each of the three components that
make up the " - Qty (3)" part of the text to make that happen?



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,344
Default Format part of text in concatenated field

Hi,

This can be done using a picture but that's a really obtuse approach, if you
want it please post back and I will step you through the process when I get
home this evening.

--
Thanks,
Shane Devenshire


"jday" wrote:

I have a formula in cell B2 that concatenates a combination of text &
contents from other cells in the worksheet. In the table below, cell C2
represents the color, cell D2 is the type of item, and cell E2 is the
quantity in inventory. For example:

C2 D2 E2
---- ---- ----
Blue Rug 3

The concatenation formula in cell B2 looks like this:

=C2&" "&D2&" - Qty ("&E2&")"

So that the result in B2 looks like this: Blue Rug - Qty (3)

What I would like is to format the "Qty (3)" portion of the text result to
be bold, or a different color, or italicized, or somehow highlighted to make
it stand out from the rest of the text in that cell. Is there a special
format code that I can insert right before each of the three components that
make up the " - Qty (3)" part of the text to make that happen?



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Format part of text in concatenated field

On Mon, 27 Oct 2008 06:45:01 -0700, jday
wrote:

I have a formula in cell B2 that concatenates a combination of text &
contents from other cells in the worksheet. In the table below, cell C2
represents the color, cell D2 is the type of item, and cell E2 is the
quantity in inventory. For example:

C2 D2 E2
---- ---- ----
Blue Rug 3

The concatenation formula in cell B2 looks like this:

=C2&" "&D2&" - Qty ("&E2&")"

So that the result in B2 looks like this: Blue Rug - Qty (3)

What I would like is to format the "Qty (3)" portion of the text result to
be bold, or a different color, or italicized, or somehow highlighted to make
it stand out from the rest of the text in that cell. Is there a special
format code that I can insert right before each of the three components that
make up the " - Qty (3)" part of the text to make that happen?



That cannot be done with a formula in the cell.

However, you could use a macro to accomplish the concatenation; write the
result to the cell as a text string, and differentially format the Qty (3)
portion.

If the entries in C, D and e are entered manually as text, then something like
below might work for you:

right click on the sheet tab
select View Code
Paste the code below into the window that opens.

Make sure the range for data entry is the correct size.

================================================
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range, c As Range
Dim sRes As String
Dim lQtyStart As Long, lQtyLen As Long
Application.EnableEvents = False
Set r = Range("C2:E100") 'set to data entry area

If Not Intersect(Target, r) Is Nothing Then
For Each c In Target
If Not Intersect(c, r) Is Nothing Then
If Application.WorksheetFunction.CountA _
(Range(Cells(c.Row, 3), Cells(c.Row, 5))) = 3 Then
sRes = Cells(c.Row, 3).Text & _
" " & Cells(c.Row, 4).Text & _
" - Qty (" & Cells(c.Row, 5).Text _
& ")"
lQtyStart = InStrRev(sRes, "(") + 1
lQtyLen = InStrRev(sRes, ")") - lQtyStart
With Cells(c.Row, 2)
.Value = sRes
.Characters(lQtyStart, lQtyLen).Font.Bold = True
.Characters(lQtyStart, lQtyLen).Font.Color = vbGreen
End With
Else
Cells(c.Row, 2).Value = ""
End If
End If
Next c
End If
Application.EnableEvents = True
End Sub
========================================

--ron
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Format part of text in concatenated field

You cannot format parts of a formula.

Either manually copy and paste as values then select the portion to
highlight or use VBA which will do the same thing.

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, "Q")
If start_str Then
Cell.Value = Cell.Value
With Cell.Characters(start_str, Len(Cell)).Font
.Bold = True
.ColorIndex = 3
End With
End If
Next
End Sub


Gord Dibben MS Excel MVP


On Mon, 27 Oct 2008 06:45:01 -0700, jday
wrote:

I have a formula in cell B2 that concatenates a combination of text &
contents from other cells in the worksheet. In the table below, cell C2
represents the color, cell D2 is the type of item, and cell E2 is the
quantity in inventory. For example:

C2 D2 E2
---- ---- ----
Blue Rug 3

The concatenation formula in cell B2 looks like this:

=C2&" "&D2&" - Qty ("&E2&")"

So that the result in B2 looks like this: Blue Rug - Qty (3)

What I would like is to format the "Qty (3)" portion of the text result to
be bold, or a different color, or italicized, or somehow highlighted to make
it stand out from the rest of the text in that cell. Is there a special
format code that I can insert right before each of the three components that
make up the " - Qty (3)" part of the text to make that happen?



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
How to make a field created a part of the Pivot Table Field List? drhell Excel Discussion (Misc queries) 0 January 29th 07 11:13 PM
Text as part of Cell Format evan Excel Discussion (Misc queries) 1 November 3rd 06 05:48 PM
format part of text in a cell? Yawrood Excel Discussion (Misc queries) 8 June 2nd 06 12:58 AM
format a number concatenated with text jmwismer Excel Discussion (Misc queries) 2 February 23rd 06 04:50 PM
How do I format text that is part of a formula? TJ Excel Discussion (Misc queries) 5 December 29th 05 07:54 PM


All times are GMT +1. The time now is 01:54 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"