Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default add a word to text in a cell

I have a text string in a cell and I want to add a new text string in front
of the existing text string in the same cell. For example, the word "place"
is already in the cell and I want to add the word "this" in front of the word
"place" to form a new string in the cell that is "this place". How would I do
this in visual basic?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default add a word to text in a cell

Alan

in Excel, you would do a global replace of "place" by "this place". Record
a macro while you do this manually and that should give you the code that
you need.

Regards

Trevor


"AlanG" wrote in message
...
I have a text string in a cell and I want to add a new text string in front
of the existing text string in the same cell. For example, the word
"place"
is already in the cell and I want to add the word "this" in front of the
word
"place" to form a new string in the cell that is "this place". How would I
do
this in visual basic?



  #3   Report Post  
Posted to microsoft.public.excel.programming
AG AG is offline
external usenet poster
 
Posts: 54
Default add a word to text in a cell

Trevor, doing this didn't really help me. While the word I want to add is
always going to be the same, the word that I am adding it to will be
different in each new cell. How do I copy the text string from the existing
cell to a variable that can then be combined with the new word?

"Trevor Shuttleworth" wrote:

Alan

in Excel, you would do a global replace of "place" by "this place". Record
a macro while you do this manually and that should give you the code that
you need.

Regards

Trevor


"AlanG" wrote in message
...
I have a text string in a cell and I want to add a new text string in front
of the existing text string in the same cell. For example, the word
"place"
is already in the cell and I want to add the word "this" in front of the
word
"place" to form a new string in the cell that is "this place". How would I
do
this in visual basic?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default add a word to text in a cell

Alan

VBA macro........

Sub Add_Text_Left()
Dim Cell As Range
Dim moretext As String
Dim thisrng As Range
On Error GoTo endit
Set thisrng = Range(ActiveCell.Address & "," & Selection.Address) _
.SpecialCells(xlCellTypeConstants, xlTextValues)
moretext = InputBox("Enter your Text")
For Each Cell In thisrng
Cell.Value = moretext & Cell.Value
Next
Exit Sub
endit:
MsgBox "only formulas in range"
End Sub

In the "Enter your Text" inputbox enter "this "(no quotes and note the
<space)


Gord Dibben Excel MVP

On Fri, 18 Feb 2005 15:29:07 -0800, "AlanG"
wrote:

I have a text string in a cell and I want to add a new text string in front
of the existing text string in the same cell. For example, the word "place"
is already in the cell and I want to add the word "this" in front of the word
"place" to form a new string in the cell that is "this place". How would I do
this in visual basic?


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
VLOOKUP IF Cell Contains a Word within Text DAWN Excel Discussion (Misc queries) 3 April 5th 23 01:07 PM
Pulling a word from text out of a cell Ravens Fan Excel Discussion (Misc queries) 11 February 1st 08 03:03 AM
word match in string text in cell, color format cell jpmahony Excel Discussion (Misc queries) 1 October 31st 07 03:56 PM
Omit the first word from a cell contain text Bhupinder Rayat Excel Worksheet Functions 8 October 27th 05 05:18 PM
COUNTIF text where there is more than one word in a cell Abi Excel Worksheet Functions 2 January 20th 05 03:32 AM


All times are GMT +1. The time now is 11:56 PM.

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"