ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy text from one cell to another (https://www.excelbanter.com/excel-programming/274357-copy-text-one-cell-another.html)

Christina[_2_]

Copy text from one cell to another
 
I have two collums of cells with text in each row. I want
to copy the text from one collum into the other, but not
overriding the original text. For example:

One collum has sations: 10+00
The other has LT or RT: LT
I want the final product to be: 10+00 LT
all in the same cell. I would like to be able to do this
in one command for all the rows in the sheet.

I'm not even sure where to start. Any suggestions?

Chris

Copy text from one cell to another
 
This should work.

Sub Concatenate()
'Set up
Dim colFirst As Integer
Dim colSecond As Integer
Dim rowLast As Integer
Dim rowFirst As Integer
Dim i As Integer

'Assume data located in columns A,B rows 5 to 25
colFirst = 1
colSecond = 2
rowFirst = 5
rowLast = 25

For i = rowFirst To rowLast
'Set 2nd column = 1st column + 2nd column
Cells(i, colSecond) = Cells(i, colFirst).Value & " " & Cells(i,
colSecond).Value
Next i

End Sub

"Christina" wrote in message
...
I have two collums of cells with text in each row. I want
to copy the text from one collum into the other, but not
overriding the original text. For example:

One collum has sations: 10+00
The other has LT or RT: LT
I want the final product to be: 10+00 LT
all in the same cell. I would like to be able to do this
in one command for all the rows in the sheet.

I'm not even sure where to start. Any suggestions?




steve

Copy text from one cell to another
 
Christina,

Assuming that you are using columns A & B and assuming
that I am understanding your question.

Sub FixMyCells()

Dim x as long

For x = 1 to Cells(Rows.COUNT, "A").End(xlUp).Row
cells(x,2) = cells(x,1) & cells(x,2)
Next

End Sub

Add & " " between the cells if you want a space.
cells(x,2) = cells(x,1) & " " & cells(x,2)
You might want to change each of the cells() statements to
cells().Text

steve

"Christina" wrote in message
...
I have two collums of cells with text in each row. I want
to copy the text from one collum into the other, but not
overriding the original text. For example:

One collum has sations: 10+00
The other has LT or RT: LT
I want the final product to be: 10+00 LT
all in the same cell. I would like to be able to do this
in one command for all the rows in the sheet.

I'm not even sure where to start. Any suggestions?





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

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