BOLDING and UNDERLINING CONCATENATED CELLS

GNoel

New Member
Joined
Feb 7, 2006
Messages
10
I need help bolding and underlining cells that are "Concatenated". For example, cell format for cell K12 is already bolded and underlined. If I concatenate (C1,K12,D2) I get a result that doesn't carry over the format of those individual cells - particularly K12 which I want BOLDED and UNDERLINED. Can anyone please help.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hello, Gnoel,

when using formulas you cannot "divide" the format
using some code you can paste the different values and copy their formats
I did only succeed using a (tiny) space between the values
try this
Code:
Option Explicit

Sub test()
Call concatenate_cells_formats(Range("A1"), Range("C1,K12,D2"))
End Sub

Sub concatenate_cells_formats(cell As Range, source As Range)
'Erik Van Geit
'060424

Dim c As Range
Dim i As Integer

i = 1
With cell
.Value = vbNullString
.ClearFormats
    For Each c In source
    .Value = .Value & " " & c
    Next c
.Value = Trim(.Value)
    For Each c In source
        With .Characters(Start:=i, Length:=Len(c)).Font
        .Name = c.Font.Name
        .FontStyle = c.Font.FontStyle
        .Size = c.Font.Size
        .Strikethrough = c.Font.Strikethrough
        .Superscript = c.Font.Superscript
        .Subscript = c.Font.Subscript
        .OutlineFont = c.Font.OutlineFont
        .Shadow = c.Font.Shadow
        .Underline = c.Font.Underline
        .ColorIndex = c.Font.ColorIndex
        End With
        .Characters(Start:=i + Len(c), Length:=1).Font.Size = 1
    i = i + Len(c) + 1
    Next c
End With

End Sub
kind regards,
Erik
 
Upvote 0
Concatenate..

Erik,

Thanks for the reply. Unfortunately, I'm still a novice at this and might need more help than I thought. So what formula do I type in the cell if I want to underline K12 in CONCATENATE (C1,K12,D2)?

Noel
 
Upvote 0
Re: Concatenate..

Erik,

Thanks for the reply. Unfortunately, I'm still a novice at this and might need more help than I thought. So what formula do I type in the cell if I want to underline K12 in CONCATENATE (C1,K12,D2)?

Noel
the answer was in my reply: you can't
Hello, Gnoel,
when using formulas you cannot "divide" the format
therefore you recieved some code to do this

first try out the code
later we can change it to your suits...
start the Visual Basic Editor (via Menu Tools, Macro or press ALT+F11).
On the Insert menu in the VBE, click Module. (if necessary)
In the module (the white area at the right), paste your code:

to run the code
click anywhere in the code and hit function key F5
or
via Excel menu: Tools / Macro / Macros (or hit Alt+F8)


assign shortcutkey
menu Tools/Macro/Macros
select your macro
click options
choose a character as shortcut: example T
to run the macro press Ctrl+Shift+T

best regards,
Erik
 
Upvote 0
Underlining concatenated cells

I've tried the macro and the result is not what I expected.

When I have the formula ... =CONCATENATE (B1,C1,D1) ... and run the macro....the result is contents of A1 is replaced by contents of C1.

This is awesome. Outstanding work. Can you help me though with my real problem.

If B1 contains "He "
C1 contains "loves "
D1 contains "her."

If I type in cell E1 the formula =CONCATENATE (B1,C1,D1)....I want the result in cell E1 to appear as ..... He loves her.
But I want loves to be underlined or in bold or both.

Thanks.
 
Upvote 0
Hi,

for the third time I will answer the same
you can NOT use a formula and have part of the contents in another format

you can copy different formats in one cell WITHOUT formula
you can edti the code from above to your needs
change this line
Call concatenate_cells_formats(Range("A1"), Range("C1,K12,D2")) Call
Code:
concatenate_cells_formats(Range("A1"), Range("C1,K12,D2"))
regarding your last question the code should be
Code:
concatenate_cells_formats(Range("E1"), Range("B1,C1,D1"))

if you can make this work for you, we can try to automate the process if you want
(example; whenever the contents of a cell in columns B, C or D is changed, column E would be updated)
best regards,
Erik
 
Upvote 0
bump
I need this macro to work for multiple rows. In your example A1 is the cell where final concatenated object would go. I want this formula to work for all cells in column A or if possible whenever I highlight a cell and click the macro shortcut it will work for that row and output it into that rows A cell.
(eg I click row A and press macro shortcut and the concatenated value with same format is outputted in A3).
 
Upvote 0
I'd like to know if there is a way to have this macro do multiple rows at the same time. For example in A1, concatenate B1,C1,D1. In A2, concatenate B2,C2,D2 etc...
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top