ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Text Functions (https://www.excelbanter.com/excel-discussion-misc-queries/175389-text-functions.html)

wilson o

Text Functions
 
Can I have text from cells in one coloumn automatically added to the
beginning of anything that is typed in the same row of another coloumn?

Gord Dibben

Text Functions
 
You could use a formula and helper column

A1 contains "this is"

In C1 enter this formula =A1 & " " B1 Note: the " " adds a space.

In B1 type "combined text"

C1 will return "this is combined text"

To have it happen without a formula you would need VBA event code.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo endit
If Target.Column = 2 Then
Application.EnableEvents = False
With Target
.Value = .Offset(0, -1).Value & " " & .Value
End With
End If
endit:
Application.EnableEvents = True
End Sub

When you type text in column B then hit enter, that text will be prefaced by the
text in Column A

This is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste into that sheet module. Alt + q to go back to Excel window.


Gord Dibben MS Excel MVP


On Sat, 2 Feb 2008 18:04:01 -0800, wilson o
wrote:

Can I have text from cells in one coloumn automatically added to the
beginning of anything that is typed in the same row of another coloumn?



wilson o

Text Functions
 
Thank you.

"Gord Dibben" wrote:

You could use a formula and helper column

A1 contains "this is"

In C1 enter this formula =A1 & " " B1 Note: the " " adds a space.

In B1 type "combined text"

C1 will return "this is combined text"

To have it happen without a formula you would need VBA event code.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo endit
If Target.Column = 2 Then
Application.EnableEvents = False
With Target
.Value = .Offset(0, -1).Value & " " & .Value
End With
End If
endit:
Application.EnableEvents = True
End Sub

When you type text in column B then hit enter, that text will be prefaced by the
text in Column A

This is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste into that sheet module. Alt + q to go back to Excel window.


Gord Dibben MS Excel MVP


On Sat, 2 Feb 2008 18:04:01 -0800, wilson o
wrote:

Can I have text from cells in one coloumn automatically added to the
beginning of anything that is typed in the same row of another coloumn?





All times are GMT +1. The time now is 09:52 AM.

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