DresdenStudent
New Member
- Joined
- Jun 4, 2018
- Messages
- 4
Hi All,
For a project I need to sort two lists of genes with each other. I found a script online that now works for my data set, but I have an issue with the header. I have added an extra header row, that now is continuously sorted with my data list. Does anyone have a suggestion?
The code is:
For a project I need to sort two lists of genes with each other. I found a script online that now works for my data set, but I have an issue with the header. I have added an extra header row, that now is continuously sorted with my data list. Does anyone have a suggestion?
The code is:
Code:
Sub CompareGenes()
'Author: Jerry Beaucaire
'Date: 10/27/2010
'Summary: Align codes in columns C and D removing all D values not in C
Dim i As Long, LR As Long
Application.ScreenUpdating = False
'Last row with data in column F
LR = Range("F" & Rows.Count).End(xlUp).Row
'Sort both section so numbers are ascending in E and F
Columns("A:E").Sort Key1:=Range("A3"), order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
Columns("F:J").Sort Key1:=Range("F3"), order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
'line up remaining items so A lines up with E
i = 2
Do
If Cells(i, "A") > Cells(i, "F") And Cells(i, "F") > "" Then
Cells(i, "A").Resize(1, 5).Insert xlShiftDown
ElseIf Cells(i, "A") < Cells(i, "F") And Cells(i, "E") > "" Then
Cells(i, "F").Resize(1, 5).Insert xlShiftDown
End If
i = i + 1
Loop Until Cells(i, "A") = "" And Cells(i, "F") = ""
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: