Add cell content to another cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
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
 
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.
 
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
 
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.
 
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)
 
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.
 
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top