![]() |
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! |
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 |
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 |
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 |
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. |
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 |
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. |
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. |
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 |
All times are GMT +1. The time now is 12:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com