![]() |
Combine data in two columns into one and sort the combined column alphabetically..how??
I have two columns, A and B. Each column contains a list of data in
text format e.g. 01TI518A.PV . It is possible that duplicates of this text may appear within either column. Also, the number of data values in each column is variable as they are imported from an external source into the worksheet. I would like to be able to combine the text from both columns into a single list in a single column, say column C. I would also like this column to be alphanumerically sorted. How do I go about doing this? |
Combine data in two columns into one and sort the combined column
Sub mergecolumns()
LastrowA = Cells(Rows.Count, "A").End(xlUp).Row LastrowB = Cells(Rows.Count, "B").End(xlUp).Row If LastrowA LastrowB Then LastRow = LastrowA Else LastRow = LastrowB End If Set SourceRange = Range(Cells(1, "A"), Cells(LastRow, "B")) RowCount = 1 For Each cell In SourceRange If Not IsEmpty(cell.Value) Then If RowCount = 1 Then Cells(1, "D") = cell.Value RowCount = RowCount + 1 Else Set DestRange = Range(Cells(1, "D"), _ Cells(RowCount - 1, "D")) Set c = DestRange.Find(what:=cell, LookIn:=xlValues) If c Is Nothing Then Cells(RowCount, "D") = cell.Value RowCount = RowCount + 1 End If End If End If Next cell Range(Cells(1, "D"), Cells(RowCount - 1, "D")).Sort _ Key1:=Range("D1"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End Sub "Tommy" wrote: I have two columns, A and B. Each column contains a list of data in text format e.g. 01TI518A.PV . It is possible that duplicates of this text may appear within either column. Also, the number of data values in each column is variable as they are imported from an external source into the worksheet. I would like to be able to combine the text from both columns into a single list in a single column, say column C. I would also like this column to be alphanumerically sorted. How do I go about doing this? |
Combine data in two columns into one and sort the combined columnalphabetically..how??
Check your other posts, too.
Tommy wrote: I have two columns, A and B. Each column contains a list of data in text format e.g. 01TI518A.PV . It is possible that duplicates of this text may appear within either column. Also, the number of data values in each column is variable as they are imported from an external source into the worksheet. I would like to be able to combine the text from both columns into a single list in a single column, say column C. I would also like this column to be alphanumerically sorted. How do I go about doing this? -- Dave Peterson |
Combine data in two columns into one and sort the combined column alphabetically..how??
In , Dave Peterson
spake thusly: Check your other posts, too. IOW: "It is possible that duplicates of this text may appear in" other posts. :-) Tommy wrote: I have two columns, A and B. Each column contains a list of data in text format e.g. 01TI518A.PV . It is possible that duplicates of this text may appear within either column. Also, the number of data values in each column is variable as they are imported from an external source into the worksheet. I would like to be able to combine the text from both columns into a single list in a single column, say column C. I would also like this column to be alphanumerically sorted. How do I go about doing this? =dman= |
Combine data in two columns into one and sort the combined column alphabetically..how??
On 10 Aug, 01:39, Dallman Ross <dman@localhost. wrote:
In , Dave Peterson spake thusly: Check your other posts, too. IOW: "It is possible that duplicates of this text may appear in" other posts. :-) Tommy wrote: I have two columns, A and B. Each column contains a list of data in text format e.g. 01TI518A.PV . It is possible that duplicates of this text may appear within either column. Also, the number of data values in each column is variable as they are imported from an external source into the worksheet. I would like to be able to combine the text from both columns into a single list in a single column, say column C. I would also like this column to be alphanumerically sorted. How do I go about doing this? =dman= many thanks for your help. i post so that i get an answer, spreading my chances as it were. well done for pointing that out in your pointless post. |
All times are GMT +1. The time now is 04:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com