ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Append to a cell (https://www.excelbanter.com/excel-programming/429376-append-cell.html)

diacci1st

Append to a cell
 
Hi
I have a lst of values and a " add " button, I would like for the user to be
able to make selections and to have the results appended to a single cell so
eg:
So if I select Value 1 then click "Add" then Value 3 than "add" lets say
cell "a1" will have in it Value 1 and Value 3 as results... how can I do that?

Jim Cone[_2_]

Append to a cell
 
Here is one approach.
User must select two separate cells before running the sub.
Lots still left to do if you want to make it reliable...
'--
Sub PutTogether()
Dim rng As Range
Dim rOne As Range
Dim rTwo As Range

Set rng = Selection
Set rOne = rng.Areas(1)(1)
Set rTwo = rng.Areas(2)(1)

rOne.Value = rOne.Value & " " & rTwo.Value
End Sub
--
Jim Cone
Portland, Oregon USA



"diacci1st"

wrote in message
Hi
I have a lst of values and a " add " button, I would like for the user to be
able to make selections and to have the results appended to a single cell so
eg:
So if I select Value 1 then click "Add" then Value 3 than "add" lets say
cell "a1" will have in it Value 1 and Value 3 as results... how can I do that?

Jim Cone[_2_]

Append to a cell
 
Here is one approach.
User must select two separate cells before running the sub.
Lots still left to do if you want to make it reliable...
'--
Sub PutTogether()
Dim rng As Range
Dim rOne As Range
Dim rTwo As Range

Set rng = Selection
Set rOne = rng.Areas(1)(1)
Set rTwo = rng.Areas(2)(1)

rOne.Value = rOne.Value & " " & rTwo.Value
End Sub
--
Jim Cone
Portland, Oregon USA



"diacci1st"

wrote in message
Hi
I have a lst of values and a " add " button, I would like for the user to be
able to make selections and to have the results appended to a single cell so
eg:
So if I select Value 1 then click "Add" then Value 3 than "add" lets say
cell "a1" will have in it Value 1 and Value 3 as results... how can I do that?

Patrick Molloy

Append to a cell
 
put this code into a sub and link your Add button to it

dim cell as range
dim text as string
text = range("A1").Value
for each cell in selection.cells
text = text & "," & cell.value
next
range("A1")=text


"diacci1st" wrote in message
...
Hi
I have a lst of values and a " add " button, I would like for the user to
be
able to make selections and to have the results appended to a single cell
so
eg:
So if I select Value 1 then click "Add" then Value 3 than "add" lets say
cell "a1" will have in it Value 1 and Value 3 as results... how can I do
that?




All times are GMT +1. The time now is 11:46 AM.

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