Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I would like to copy the cells from column A and column B (entire range) into column C. How can I automate this process so that it constantly copies newly added cells to column A or B into column C, and then sorts column C ascending?

Do you mean you want to combine the data in a row for Column A and B and then copy that result into Column C? What is the format of the data in A and B?
Soylent Green is PEOPLE!!!

I would do it this way:
In cell C =Sum(A1+B1) copy the formula as needed for the number of rows.Copy and paste this into the visual basic editor:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheets("Sheet1").Range("C1").Sort Key1:=Worksheets("Sheet1").Column("C"),Header:=xlGuess
End Sub
Note: The middle line "Worksheets...xlGuess" is one line of code

If you are "adding" (concatenating) text then the formula would be = A1&" "&B1
that assumes you want to add a space betweent he two values. If not, it would be just =A1&B1
Michael J

I do not wish to combine the data in rows A and B. The data in these rows will be text.
For example, if A1 contains "65G-123" and B1 contains "65F-43", I want C1 to automatically contain "65F-43" and C2 to contain "65G-123", in that order (sorted ascending). If I add the value "65A-333" to A2, I would like the C column to reorder itself as:
C1: "65A-333"
C2: "65F-43"
C3: "65G-123"Hope that clears things up a bit.
Thanks for your responses so far!

I came up with this using column D for the sorting of the contents of A & B. It would take some refining but, it might give you some ideas. Hope it helps you.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim I As Integer
Dim myval
Dim myval2With Columns("D")
.Clear
.NumberFormat = "@"
End With
For Each cel In UsedRange
cel.NumberFormat = "@"
r = r + 1
If cel.Value > "" Then Cells(r, 4) = cel.Value
Next
Worksheets("Sheet1").Range("D1").Sort
Key1:=Worksheets("Sheet1").Columns("D"), Header:=xlGuess
End SubNote: the last 3 lines before end sub, is one line of code

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |