Putting text together from 3 cells

J

john.9.williams

Hi i have 3 cells a1 a2 a3 all with about 2 sentences of data in, i
want to take all that data and put it in one cell, however i wish to
seperate each piece of data from each cell with a carrige line space
and title like below

go from this :

cell a1: helloe i am the data in a1
cell a2: hello i am the data in a2
cell a3: hello i am the data in a3

to this

cell b1: a1 data
hello i am the data in a1

a2 data
hello i am the data in a2

a3 data
hello i am the data in a3

hope this makes sense, been trying to solve this but cannot get the
line spaces or add the titles to each cell value
 
R

Rick Rothstein \(MVP - VB\)

Although you posted in the programming newsgroup, you can do what you want
with a worksheet formula...

="a1 data"&CHAR(10)&A1&CHAR(10)&CHAR(10)&"a2
data"&CHAR(10)&A2&CHAR(10)&CHAR(10)&"a3 data"&CHAR(10)&A3

Rick
 
J

john.9.williams

Although you posted in the programming newsgroup, you can do what you want
with a worksheet formula...

="a1 data"&CHAR(10)&A1&CHAR(10)&CHAR(10)&"a2
data"&CHAR(10)&A2&CHAR(10)&CHAR(10)&"a3 data"&CHAR(10)&A3

Rick













- Show quoted text -

thanks,

I wanted to know if i could do it with a macro as the 3 cells i wish
to put together could be any where, i want to try and click on the
first of the 3 cells, press the button and them the cells join
together on another part of the spreadsheet,
 
R

Rick Rothstein \(MVP - VB\)

And if you needed the code in a macro...

Sub CombineText()
With Worksheets("Sheet1")
.Range("B1").Cells.WrapText = True
.Range("B1").Value = "a1 data" & vbLf & .Range("A1") & _
vbLf & vbLf & _
"a2 data" & vbLf & .Range("A2") & _
vbLf & vbLf & _
"a3 data" & vbLf & .Range("A3")
End With
End Sub

By the way, notice that I take care of formatting B1 to wrap its text in the
code... don't forget that if you use my worksheet formula, you have to do
that manually.

Rick
 
R

Rick Rothstein \(MVP - VB\)

This code will put the text from the active cell and the two cells below it
into B1 on Sheet1 (you can change destination cell in the With statement)..

Sub CombineText()
With Worksheets("Sheet1").Range("B1")
.Cells.WrapText = True
.Value = "a1 data" & vbLf & ActiveCell.Value & _
vbLf & vbLf & _
"a2 data" & vbLf & ActiveCell.Offset(1, 0).Value & _
vbLf & vbLf & _
"a3 data" & vbLf & ActiveCell.Offset(2, 0).Value
End With
End Sub

Rick


Although you posted in the programming newsgroup, you can do what you want
with a worksheet formula...

="a1 data"&CHAR(10)&A1&CHAR(10)&CHAR(10)&"a2
data"&CHAR(10)&A2&CHAR(10)&CHAR(10)&"a3 data"&CHAR(10)&A3

Rick













- Show quoted text -

thanks,

I wanted to know if i could do it with a macro as the 3 cells i wish
to put together could be any where, i want to try and click on the
first of the 3 cells, press the button and them the cells join
together on another part of the spreadsheet,
 

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

Top