Fix Gene Names Turned into Dates Problem

I became aware of this issue in http://www.sciencemag.org/news/sifter/one-five-genetics-papers-contains-errors-thanks-microsoft-excel?utm_source=newsfromscience&utm_medium=facebook-text&utm_campaign=excel-6929.

The following user-defined Function is a start. You can add to the Case statement to add whatever gene names you like, with the caveat that once Excel finds a match, it will jump out of the Case statement.

Add this to your Personal Macro Workbook and save it.

You can then find the function in the User Defined Functions category of the Function Wizard. Add the function to a separate column, reference the first cell with the problem, copy it down the column, then Copy | Paste | Values into the same column to convert the function into text. It should ignore any name that has not been turned into a date. (For example, if cell B2 contains the first Gene name, add the function =FixGeneName(B2) into the next blank column at row 2 and copy it down.)

This is a start at solving the problem. It should work internationally, using the Language settings for the PC. It should work on a Mac, assuming you have a version of Office that includes Visual Basic.

Function FixGeneName(GeneText As String) As String
Dim intMonth As Integer
Dim intDay As Integer

 On Error Resume Next
 intMonth = month(GeneText)
 intDay = day(GeneText)
 
 Select Case intMonth
 Case 1: FixGeneName = "JA" & intDay
 Case 2: FixGeneName = "FE" & intDay
 Case 3: FixGeneName = "MA" & intDay
 Case 4: FixGeneName = "AP" & intDay
 Case 5: FixGeneName = "MA" & intDay
 Case 6: FixGeneName = "JU" & intDay
 Case 7: FixGeneName = "JU" & intDay
 Case 8: FixGeneName = "AU" & intDay
 Case 9: FixGeneName = "SEPT" & intDay
 Case 10: FixGeneName = "OC" & intDay
 Case 11: FixGeneName = "NO" & intDay
 Case 12: FixGeneName = "DE" & intDay
 Case Else:
 FixGeneName = GeneText
 End Select

 On Error GoTo 0
 
End Function

Leave a Reply

Your email address will not be published. Required fields are marked *