Sub datainput() ' Macro recorded 2/7/2006 by Hana Lee 'SORT BY ORDER ALONG CHROMOSOME Dim i Columns("A:A").Select For i = 1 To 9 Step 1 Selection.Replace What:="_" & i & "_", Replacement:="_0" & i & "_", LookAt:=xlPart Next i Columns("A:C").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal 'AVERAGE ALL REPLICATES Range("A1").Select Do While IsEmpty(ActiveCell) = False If ActiveCell.Formula Like "*_R" = True _ Or ActiveCell.Formula Like "*_A" = True Then Range(ActiveCell, ActiveCell.Offset(0, 2)).Insert Shift:=xlDown ActiveCell.Formula = ActiveCell.Offset(1, 0).Formula ActiveCell.Offset(0, 1).Formula = ActiveCell.Offset(1, 1).Formula If ActiveCell.Offset(2, 0).Formula Like "*_RA" = True Then With ActiveCell.Offset(0, 2) .FormulaR1C1 = "=AVERAGE(R[1]C,R[2]C,R[3]C)" .Copy .PasteSpecial Paste:=xlPasteValues End With ActiveCell.Offset(0, -2).Select Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(3, 2)).Delete Shift:=xlUp Else With ActiveCell.Offset(0, 2) .FormulaR1C1 = "=AVERAGE(R[1]C,R[2]C)" .Copy .PasteSpecial Paste:=xlPasteValues End With ActiveCell.Offset(0, -2).Select Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(2, 2)).Delete Shift:=xlUp End If End If ActiveCell.Offset(1, 0).Select Loop Columns("C:C").Replace What:="#DIV/0!", Replacement:="", LookAt:=xlPart With Columns("A:A") .Replace What:="_RA", Replacement:="", LookAt:=xlPart .Replace What:="_R", Replacement:="", LookAt:=xlPart .Replace What:="_A", Replacement:="", LookAt:=xlPart End With End Sub