ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Concatenation 2 Texts (https://www.excelbanter.com/excel-discussion-misc-queries/110385-concatenation-2-texts.html)

Hi_no_Tori

Concatenation 2 Texts
 
Suppose I have two Texts: "Text1" in A1 and "Text2" in C1. I want to make a
concatenation of A1 and C1 in cell C3, and make the font of "Text1" bold, but
not "Text2". Is there a way to do this in Excel?

Bob Phillips

Concatenation 2 Texts
 
You would need VBA.

With ActiveCell
.Value = Range("A1").Value & Range("C1").Value
.Characters(Len(Range("A1").Value) + 1, _
Len(Range("C1").Value)).Font.Bold = True
End With


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Hi_no_Tori" wrote in message
...
Suppose I have two Texts: "Text1" in A1 and "Text2" in C1. I want to make

a
concatenation of A1 and C1 in cell C3, and make the font of "Text1" bold,

but
not "Text2". Is there a way to do this in Excel?




Hi_no_Tori

Concatenation 2 Texts
 
Tanks a lot, Bob. It works, but... I need "Text1" to be bold not "Text2" and
I need to seperate between "text1" and "Text2" e.g. by the sign: "-". I'll be
very thankful if you can help.

"Bob Phillips" wrote:

You would need VBA.

With ActiveCell
.Value = Range("A1").Value & Range("C1").Value
.Characters(Len(Range("A1").Value) + 1, _
Len(Range("C1").Value)).Font.Bold = True
End With


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Hi_no_Tori" wrote in message
...
Suppose I have two Texts: "Text1" in A1 and "Text2" in C1. I want to make

a
concatenation of A1 and C1 in cell C3, and make the font of "Text1" bold,

but
not "Text2". Is there a way to do this in Excel?





Bob Phillips

Concatenation 2 Texts
 
No problem

With ActiveCell
.Value = Range("A1").Value & "-" & Range("C1").Value
.Characters(1, Len(Range("A1").Value) ) _
.Font.Bold = True
End With


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Hi_no_Tori" wrote in message
...
Tanks a lot, Bob. It works, but... I need "Text1" to be bold not "Text2"

and
I need to seperate between "text1" and "Text2" e.g. by the sign: "-". I'll

be
very thankful if you can help.

"Bob Phillips" wrote:

You would need VBA.

With ActiveCell
.Value = Range("A1").Value & Range("C1").Value
.Characters(Len(Range("A1").Value) + 1, _
Len(Range("C1").Value)).Font.Bold = True
End With


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Hi_no_Tori" wrote in message
...
Suppose I have two Texts: "Text1" in A1 and "Text2" in C1. I want to

make
a
concatenation of A1 and C1 in cell C3, and make the font of "Text1"

bold,
but
not "Text2". Is there a way to do this in Excel?







Hi_no_Tori

Concatenation 2 Texts
 
Once again, thank you very much for your help and your fast response Bob. I
tried it and it works... But I still need some help. I need the concatenation
to be in a fixed cell (e.g. D12), instead of the active cell... I tried the
following code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Range("D12")
.Value = Range("A1").Value & "-" & Range("C1").Value
.Characters(1, Len(Range("A1").Value)) _
.Font.Bold = True
End With

It works at first, but once I click on any cell, all the text in D12 becomes
bold. Can you do something to make it work properly... It will be great if
you can help. If you can't, it's o.k. and I'm very thankful to you for trying
helping me before.


Bob Phillips

Concatenation 2 Texts
 
Best to clear it first

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Range("D12")
.Font.Bold = False
.Value = Range("A1").Value & "-" & Range("C1").Value
.Characters(1, Len(Range("A1").Value)) _
.Font.Bold = True
End With
End Sub

A small problem here is that it fires every time you select a cell, any c
ell. It would be better to be targeted at one particular cell. When do you
want the setup and formatting to happen?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Hi_no_Tori" wrote in message
...
Once again, thank you very much for your help and your fast response Bob.

I
tried it and it works... But I still need some help. I need the

concatenation
to be in a fixed cell (e.g. D12), instead of the active cell... I tried

the
following code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Range("D12")
.Value = Range("A1").Value & "-" & Range("C1").Value
.Characters(1, Len(Range("A1").Value)) _
.Font.Bold = True
End With

It works at first, but once I click on any cell, all the text in D12

becomes
bold. Can you do something to make it work properly... It will be great if
you can help. If you can't, it's o.k. and I'm very thankful to you for

trying
helping me before.




Hi_no_Tori

Concatenation 2 Texts
 
Hi Bob...

Here is what I am trying to do exactly:

I have a text in cell A1, and another text in cell C1. I need to concatenate
them in cell D12. The font of the text from A1 should be normal, while the
text from cell C1 should be bold. I need to seperate between the two texts by
the sign " - ". I need this formatting to happen after I enter or modify the
text in cell A1 and cell C1.

I tried the code you have provided me with in your last post (the modified
one). Unlike before, it seems to work fine now. When I click on a cell now,
cell D12 formatting remains the same (i.e. Text from A1 normal, and Text from
C1 bold). That's basically what I need...

Thank you SO MUCH for your great help Bob. (^_^)

Bob Phillips

Concatenation 2 Texts
 
This should also work, and is better as it fires ONLY when A1 or C1 is
changed

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1,C1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Range("D12")
.Font.Bold = False
.Value = Range("A1").Value & "-" & Range("C1").Value
.Characters(1, Len(Range("A1").Value)) _
.Font.Bold = True
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Just remove your code and replace with that, the whole procedure.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Hi_no_Tori" wrote in message
...
Hi Bob...

Here is what I am trying to do exactly:

I have a text in cell A1, and another text in cell C1. I need to

concatenate
them in cell D12. The font of the text from A1 should be normal, while the
text from cell C1 should be bold. I need to seperate between the two texts

by
the sign " - ". I need this formatting to happen after I enter or modify

the
text in cell A1 and cell C1.

I tried the code you have provided me with in your last post (the modified
one). Unlike before, it seems to work fine now. When I click on a cell

now,
cell D12 formatting remains the same (i.e. Text from A1 normal, and Text

from
C1 bold). That's basically what I need...

Thank you SO MUCH for your great help Bob. (^_^)




Hi_no_Tori

Concatenation 2 Texts
 
Hi Bob...

I've just tried the code, and It's working perfectly. Many, many thanks
indeed. Thanks to you Bob, my problem is now solved. (^_^)

"Bob Phillips" wrote:

This should also work, and is better as it fires ONLY when A1 or C1 is
changed

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1,C1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Range("D12")
.Font.Bold = False
.Value = Range("A1").Value & "-" & Range("C1").Value
.Characters(1, Len(Range("A1").Value)) _
.Font.Bold = True
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Just remove your code and replace with that, the whole procedure.

--
HTH

Bob Phillips




All times are GMT +1. The time now is 04:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com