Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Add cell content to another cell

Hi, how can I copy the complete content of one cell and add it to the end of
the content in another cell? Example: in one cell I have London, in the next
cell I have UK and I want the first cell to be London (UK). Ideally I would
like some kind of macro so I can choose the source and destination cells.
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Add cell content to another cell

Hi, This would do the trick i think

Sub ConcatenateTwoCells()
Src = InputBox("Which cell's content do you want to append to another
cell?")
Dst = InputBox("To which cell do you want to append the contents of
cell " & Src)
Range(Dst) = Range(Dst) & Range(Src)
End Sub

Regards,
ManualMan
http://www.gamesXL.tk

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Add cell content to another cell

Thanks for your response, Manual Man. This looks like the kind of thing I
need, but I am getting a compile error saying 'expected: expression' - any
idea why? Also, is there a way of getting it to put brackets round the added
text? (Sorry for my cluelessness!) Many thanks again for your help.

"ManualMan" wrote:

Hi, This would do the trick i think

Sub ConcatenateTwoCells()
Src = InputBox("Which cell's content do you want to append to another
cell?")
Dst = InputBox("To which cell do you want to append the contents of
cell " & Src)
Range(Dst) = Range(Dst) & Range(Src)
End Sub

Regards,
ManualMan
http://www.gamesXL.tk


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Add cell content to another cell

Sub ConcatenateTwoCells()
Src = InputBox("Which cell's content do" & _
" you want to append to another cell?")
Dst = InputBox("To which cell do you want to " & _
"append the contents of cell " & Src)
Range(Dst).Text = Range(Dst).Text & _
" (" & Range(Src).Text & ")"
End Sub

--
Regards,
Tom Ogilvy

"Sophisticated Penguin"
wrote in message ...
Thanks for your response, Manual Man. This looks like the kind of thing I
need, but I am getting a compile error saying 'expected: expression' - any
idea why? Also, is there a way of getting it to put brackets round the

added
text? (Sorry for my cluelessness!) Many thanks again for your help.

"ManualMan" wrote:

Hi, This would do the trick i think

Sub ConcatenateTwoCells()
Src = InputBox("Which cell's content do you want to append to another
cell?")
Dst = InputBox("To which cell do you want to append the contents of
cell " & Src)
Range(Dst) = Range(Dst) & Range(Src)
End Sub

Regards,
ManualMan
http://www.gamesXL.tk




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Add cell content to another cell

Thanks Tom. The input boxes work fine but the line
Range(Dst).Text = Range(Dst).Text & Range(Src).Text
seems to be causing problems. Any ideas?
Thanks again to both of you for your help.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Add cell content to another cell

It works fine for me. It would depend on what you enter in the inputbox.
If you don't put in a valid cell address, it won't work.

--
Regards,
Tom Ogilvy

"Sophisticated Penguin"
wrote in message ...
Thanks Tom. The input boxes work fine but the line
Range(Dst).Text = Range(Dst).Text & Range(Src).Text
seems to be causing problems. Any ideas?
Thanks again to both of you for your help.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Add cell content to another cell

Sub ConcatenateTwoCells()
Set Src = Application.InputBox("Which cell's content do " & _
"you want to append to another cell?", Type:=8)
Set Dst = Application.InputBox("To which cell do you want to " & _
"append the contents of cell " & Src.Address, Type:=8)
Dst.Value = "(" & Dst.Value & Src.Value & ")"
End Sub

This uses Application.Inputbox which allows the cells to be mouse selected.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Sophisticated Penguin"
wrote in message ...
Thanks for your response, Manual Man. This looks like the kind of thing I
need, but I am getting a compile error saying 'expected: expression' - any
idea why? Also, is there a way of getting it to put brackets round the

added
text? (Sorry for my cluelessness!) Many thanks again for your help.

"ManualMan" wrote:

Hi, This would do the trick i think

Sub ConcatenateTwoCells()
Src = InputBox("Which cell's content do you want to append to another
cell?")
Dst = InputBox("To which cell do you want to append the contents of
cell " & Src)
Range(Dst) = Range(Dst) & Range(Src)
End Sub

Regards,
ManualMan
http://www.gamesXL.tk




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Add cell content to another cell

Tom, I think it was my fault because I didn't put the $ signs before the cell
letter and number. Bob, the application input boxes are very useful.
I must try to do some tutorials for VBA - it seems it is possible to do
almost anything if only you know how! Thank you all for your patience and
help - I'm most grateful.
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Add cell content to another cell

Maybe the error Sophisticated Penguin mentioned, is caused by two
different (non-text) cell formats. In that case, try to convert your
cell.value into a string

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 click on a cell and have the content of the cell display in a different cell [email protected] Excel Worksheet Functions 0 June 6th 06 03:05 PM
How make hyperlink refer to cell content rather than cell address. Omunene Excel Discussion (Misc queries) 3 March 2nd 06 01:07 AM
Excel - create button to replace cell content with cell value blackmot Excel Worksheet Functions 3 December 7th 05 05:10 PM
Cell Formula reference to cell Based On third Cell Content Gabriel Excel Discussion (Misc queries) 1 February 11th 05 06:36 AM
Cell Formula reference to cell Based On third Cell Content Gabriel Excel Discussion (Misc queries) 0 February 11th 05 05:35 AM


All times are GMT +1. The time now is 06:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"