VB忽略规则行

时间:2015-02-05 15:40:55

标签: excel-vba vba excel

我有一个相应的规则来对细胞进行分类。基本上有3种类型的规则,前两种规则正确运行。下面的代码用于在规则中使用代码的斜体部分。问题是第三组规则需要粗体部分和斜体部分。截至目前它不是,我不知道如何解决它。谢谢 :)。

Option Explicit

Sub Tester()
Dim iCase As Long
Dim iLastName As Long
Dim iFirstName As Long
Dim iMedicalRecord As Long
Dim iGender As Long
Dim iPanel As Long
Dim iInheritance As Long
Dim iFuncrefGene As Long
Dim iExonicFuncrefGene As Long
Dim iPopFreqMax As Long
Dim iClinVar As Long
Dim iCommon As Long
Dim iClassification As Long

Dim vCase, vLastName, vFirstName, vMedicalRecord, vGender, vPanel, vInheritance
Dim vFuncrefGene, vExonicFuncrefGene, vPopFreqMax, vClinVar, vCommon, vClassification
Dim iRow As Long
Dim i As Long, rw As Range, rData As Range

Application.ScreenUpdating = False
'set the range
Set rData = Worksheets("annovar").Cells(4, 1).CurrentRegion

Set rw = rData.Rows(1)
'search row and define criteria
With Application.WorksheetFunction
iCase = .Match("Case", rData.Rows(1))
iLastName = .Match("Last Name", rData.Rows(1), 0)
iFirstName = .Match("First Name", rData.Rows(1), 0)
iMedicalRecord = .Match("Medical Record", rData.Rows(1), 0)
iGender = .Match("Gender", rData.Rows(1), 0)
iPanel = .Match("Panel", rData.Rows(1), 0)
iInheritance = .Match("Inheritance", rData.Rows(4), 0)
iPopFreqMax = .Match("PopFreqMax", rData.Rows(4), 0)
iClinVar = .Match("ClinVar", rData.Rows(4), 0)
iCommon = .Match("Common", rData.Rows(4), 0)
iFuncrefGene = .Match("Func.refGene", rData.Rows(4), 0)
iExonicFuncrefGene = .Match("ExonicFunc.refGene", rData.Rows(4), 0)
iClassification = .Match("Classification", rData.Rows(4), 0)
End With

' Classifications
For iRow = 2 To rData.Rows.Count ‘Start at line #2 to ignore the header row

Set rw = rData.Rows(iRow)

vCase = rw(iCase).Value
vLastName = rw(iLastName).Value
vFirstName = rw(iFirstName).Value
vMedicalRecord = rw(iMedicalRecord).Value
vGender = rw(iGender).Value
vPanel = rw(iPanel).Value
vInheritance = rw(iInheritance).Value
vPopFreqMax = rw(iPopFreqMax).Value
vClinVar = rw(iClinVar).Value
vCommon = rw(iCommon).Value
vFuncrefGene = rw(iFuncrefGene).Value
vExonicFuncrefGene = rw(iExonicFuncrefGene).Value
vClassification = “”

‘pathogenic
Select Case vClinVar
    Case “pathogenic”
        vClassification = “pathogenic”
    Case “non-pathogenic”
        vClassification = “benign”
    Case “unknown”
        vClassification = “VUS”
    Case “untested”
        vClassification = “not provided”
End Select

If vInheritance = “XL” Or “unknown” Or “sporadic, AD” or “de novo, AD”  Then vClassification = “unknown”

If vClassification = “” And vClinVar = “” Then   

    If vInheritance = "AD" Then

                              ' likely pathogenic
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AD" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                            .Cells(iRow, iPopFreqMax).Value <= 0.01) Or _
                            (.Cells(iRow, iClinVar).Value = "probable-pathogenic" And _
                            .Cells(iRow, iCommon) = "") Then _
                                .Cells(iRow, iClassification).Value = "likely pathogenic"
                              ' likely benign
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AD" And _
                            .Cells(iRow, iPopFreqMax).Value >= 0.01) Or _
                           (.Cells(iRow, iCommon).Value = "Common" Or _
                            .Cells(iRow, iClinVar).Value = "probable-non-pathogenic") Then _
                                .Cells(iRow, iClassification).Value = "likely benign"
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AD" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value = "synonymous SNV" And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                            .Cells(iRow, iPopFreqMax).Value <= 0.01) Or _
                           (.Cells(iRow, iClinVar).Value = "probable-non-pathogenic" And _
                            .Cells(iRow, iCommon) = "") Then _
                                .Cells(iRow, iClassification).Value = "likely benign"


                              ' questionable
                        If .Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AD" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous SNV" And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                            .Cells(iRow, iPopFreqMax).Value <= 0.01 And _
                            .Cells(iRow, iCommon).Value = "Common" Then _
                                .Cells(iRow, iClassification).Value = "???"
                              ' unknown
                        If .Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AD" And _
                            .Cells(iRow, iPopFreqMax).Value = "" And _
                            .Cells(iRow, iCommon).Value = "" Then _
                            .Cells(iRow, iClassification).Value = "unknown"
                        End If

    If vInheritance = "AR" Then
                              ' likely pathogenic
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AR" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                            .Cells(iRow, iPopFreqMax).Value <= 0.1) Or _
                           (.Cells(iRow, iClinVar).Value = "probable-pathogenic" And _
                            .Cells(iRow, iCommon) = "") Then _
                               .Cells(iRow, iClassification).Value = "likely pathogenic"
                              ' likely benign
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AR" And _
                            .Cells(iRow, iPopFreqMax).Value >= 0.1) Or _
                            (.Cells(iRow, iCommon).Value = "Common" Or _
                            .Cells(iRow, iClinVar).Value = "probable-non-pathogenic") Then _
                                .Cells(iRow, iClassification).Value = "likely benign"
                              ' questionable
                        If .Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AR" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                            .Cells(iRow, iPopFreqMax).Value <= 0.1 And _
                            .Cells(iRow, iCommon).Value = "Common" Then _
                                .Cells(iRow, iClassification).Value = "???"
                              ' unknown
                        If .Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AR" And _
                            .Cells(iRow, iPopFreqMax).Value = "" And _
                            .Cells(iRow, iCommon).Value = "" Then _
                                .Cells(iRow, iClassification).Value = "unknown"
                        End If


   If vInheritance = "AD, AR" Then
                              ' likely pathogenic
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AD, AR" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                            .Cells(iRow, iPopFreqMax).Value <= 0.1) Or _
                           (.Cells(iRow, iClinVar).Value = "probable-pathogenic" And _
                            .Cells(iRow, iCommon) = "") Then _
                               .Cells(iRow, iClassification).Value = "likely pathogenic"
                              ' likely benign
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AD, AR" And _
                            .Cells(iRow, iPopFreqMax).Value >= 0.1) Or _
                            (.Cells(iRow, iCommon).Value = "Common" Or _
                            .Cells(iRow, iClinVar).Value = "probable-non-pathogenic") Then _
                                .Cells(iRow, iClassification).Value = "likely benign"
                              ' questionable
                        If .Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AD, AR" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                            .Cells(iRow, iPopFreqMax).Value <= 0.1 And _
                            .Cells(iRow, iCommon).Value = "Common" Then _
                                .Cells(iRow, iClassification).Value = "???"
                              ' unknown
                        If .Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "AD, AR" And _
                            .Cells(iRow, iPopFreqMax).Value = "" And _
                            .Cells(iRow, iCommon).Value = "" Then _
                                .Cells(iRow, iClassification).Value = "unknown"
                    End If

   If vInheritance = "XLD" Then
                              ' likely pathogenic
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLD" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                            .Cells(iRow, iGender).Value = "Male") Or _
                            .Cells(iRow, iGender).Value = "Female" And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                           (.Cells(iRow, iPopFreqMax).Value <= 0.01) Or _
                            .Cells(iRow, iClinVar).Value = "probable-pathogenic" And _
                            .Cells(iRow, iCommon).Value = "" Then _
                            .Cells(iRow, iClassification).Value = "likely pathogenic"
                              ' likely benign
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLD" And _
                            .Cells(iRow, iGender).Value = "Male") Or _
                            .Cells(iRow, iGender).Value = "Female" And _
                           (.Cells(iRow, iPopFreqMax).Value >= 0.01) Or _
                            .Cells(iRow, iCommon).Value = "Common" Or _
                             .Cells(iRow, iClinVar).Value = "probable-non-pathogenic" Then _
                               .Cells(iRow, iClassification).Value = "likely benign"
                              ' questionable
                        If (.Cells(iRow, iClinVar).Value = "" And _
                           .Cells(iRow, iInheritance).Value = "XLD" And _
                           .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                           .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                           .Cells(iRow, iGender).Value = "Male") Or _
                           .Cells(iRow, iGender).Value = "Female" And _
                           .Cells(iRow, iPopFreqMax).Value <> "" And _
                           (.Cells(iRow, iPopFreqMax).Value <= 0.01) Or _
                           .Cells(iRow, iCommon).Value = "Common" Then _
                              .Cells(iRow, iClassification).Value = "???"
                              ' unknown
                        If (.Cells(iRow, iClinVar).Value = "" And _
                           .Cells(iRow, iInheritance).Value = "XLD" And _
                           .Cells(iRow, iGender).Value = "Male") Or _
                           .Cells(iRow, iGender).Value = "Female" And _
                           .Cells(iRow, iPopFreqMax).Value = "" And _
                           .Cells(iRow, iCommon).Value = "" Then _
                              .Cells(iRow, iClassification).Value = "unknown"
                    End If

   If vInheritance = "XLR for male" Then
                              ' likely pathogenic
                        If (.Cells(iRow, iClinVar).Value = "" And _
                           .Cells(iRow, iInheritance).Value = "XLR" And _
                           .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                           .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                           .Cells(iRow, iGender).Value = "Male") And _
                           .Cells(iRow, iPopFreqMax).Value <> "" And _
                          (.Cells(iRow, iPopFreqMax).Value <= 0.01) Or _
                           .Cells(iRow, iClinVar).Value = "probable-pathogenic" And _
                           .Cells(iRow, iCommon).Value = "" Then _
                              .Cells(iRow, iClassification).Value = "likely pathogenic"
                              ' likely benign
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iGender).Value = "Male" And _
                           (.Cells(iRow, iPopFreqMax).Value >= 0.01) Or _
                            .Cells(iRow, iCommon).Value = "Common" Or _
                            .Cells(iRow, iClinVar).Value = "probable-non-pathogenic") Then _
                               .Cells(iRow, iClassification).Value = "likely benign"
                              ' questionable
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                            .Cells(iRow, iGender).Value = "Male") And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                            .Cells(iRow, iPopFreqMax).Value <= 0.01 And _
                            .Cells(iRow, iCommon).Value = "Common" Then _
                               .Cells(iRow, iClassification).Value = "???"
                              ' unknown
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iGender).Value = "Male") And _
                            .Cells(iRow, iPopFreqMax).Value = "" And _
                            .Cells(iRow, iCommon).Value = "" Then _
                                .Cells(iRow, iClassification).Value = "unknown"
                    End If

If vInheritance = "XLR for female" Then
                              ' likely pathogenic
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                            .Cells(iRow, iGender).Value = "Female") And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                           (.Cells(iRow, iPopFreqMax).Value <= 0.02) Or _
                            .Cells(iRow, iClinVar).Value = "probable-pathogenic" And _
                            .Cells(iRow, iCommon).Value = "" Then _
                               .Cells(iRow, iClassification).Value = "likely pathogenic"
                              ' likely benign
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iGender).Value = "Female" And _
                            .Cells(iRow, iPopFreqMax).Value >= 0.02) Or _
                           (.Cells(iRow, iCommon).Value = "Common" Or _
                            .Cells(iRow, iClinVar).Value = "probable-non-pathogenic") Then _
                               .Cells(iRow, iClassification).Value = "likely benign"
                              ' questionable
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                            .Cells(iRow, iGender).Value = "Female" And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                            .Cells(iRow, iPopFreqMax).Value <= 0.02) And _
                            .Cells(iRow, iCommon).Value = "Common" Then _
                               .Cells(iRow, iClassification).Value = "???"
                              ' unknown
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iGender).Value = "Female") And _
                            .Cells(iRow, iPopFreqMax).Value = "" And _
                            .Cells(iRow, iCommon).Value = "" Then _
                               .Cells(iRow, iClassification).Value = "unknown"
                    End If

If vInheritance = "XLD, XLR" And vGender = "Male" Then
                              ' likely pathogenic
                        If (.Cells(iRow, iClinVar).Value = "" And _
                           .Cells(iRow, iInheritance).Value = "XLR" And _
                           .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                           .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                           .Cells(iRow, iGender).Value = "Male") And _
                           .Cells(iRow, iPopFreqMax).Value <> "" And _
                          (.Cells(iRow, iPopFreqMax).Value <= 0.01) Or _
                           .Cells(iRow, iClinVar).Value = "probable-pathogenic" And _
                           .Cells(iRow, iCommon).Value = "" Then _
                              .Cells(iRow, iClassification).Value = "likely pathogenic"
                              ' likely benign
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iGender).Value = "Male" And _
                           (.Cells(iRow, iPopFreqMax).Value >= 0.01) Or _
                            .Cells(iRow, iCommon).Value = "Common" Or _
                            .Cells(iRow, iClinVar).Value = "probable-non-pathogenic") Then _
                               .Cells(iRow, iClassification).Value = "likely benign"
                              ' questionable
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                            .Cells(iRow, iGender).Value = "Male") And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                            .Cells(iRow, iPopFreqMax).Value <= 0.01 And _
                            .Cells(iRow, iCommon).Value = "Common" Then _
                               .Cells(iRow, iClassification).Value = "???"
                              ' unknown
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iGender).Value = "Male") And _
                            .Cells(iRow, iPopFreqMax).Value = "" And _
                            .Cells(iRow, iCommon).Value = "" Then _
                                .Cells(iRow, iClassification).Value = "unknown"
                    End If

If vInheritance = "XLD, XLR" And vGender = "Female" Then
                              ' likely pathogenic
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                            .Cells(iRow, iGender).Value = "Female") And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                           (.Cells(iRow, iPopFreqMax).Value <= 0.02) Or _
                            .Cells(iRow, iClinVar).Value = "probable-pathogenic" And _
                            .Cells(iRow, iCommon).Value = "" Then _
                               .Cells(iRow, iClassification).Value = "likely pathogenic"
                              ' likely benign
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iGender).Value = "Female" And _
                            .Cells(iRow, iPopFreqMax).Value >= 0.02) Or _
                           (.Cells(iRow, iCommon).Value = "Common" Or _
                            .Cells(iRow, iClinVar).Value = "probable-non-pathogenic") Then _
                               .Cells(iRow, iClassification).Value = "likely benign"
                              ' questionable
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iFuncrefGene).Value = "exonic" And _
                            .Cells(iRow, iExonicFuncrefGene).Value <> "synonymous" And _
                            .Cells(iRow, iGender).Value = "Female" And _
                            .Cells(iRow, iPopFreqMax).Value <> "" And _
                            .Cells(iRow, iPopFreqMax).Value <= 0.02) And _
                            .Cells(iRow, iCommon).Value = "Common" Then _
                               .Cells(iRow, iClassification).Value = "???"
                              ' unknown
                        If (.Cells(iRow, iClinVar).Value = "" And _
                            .Cells(iRow, iInheritance).Value = "XLR" And _
                            .Cells(iRow, iGender).Value = "Female") And _
                            .Cells(iRow, iPopFreqMax).Value = "" And _
                            .Cells(iRow, iCommon).Value = "" Then _
                               .Cells(iRow, iClassification).Value = "unknown"
                    End If
‘ Populate classification value
rw(iClassification).Value = vClassification

Next iRow

1 个答案:

答案 0 :(得分:0)

你的问题中有大量的代码,并且可以通过不反复测试相同的东西来大大减少。

我首先要使用值的实际变量,而不是每次都使用表格:单独执行此操作会显着减少代码量。

您也只需要遍历行一次 - 只需在每一行上运行每个测试,直到获得Classification的值。当您重复代码时,它更难以遵循,任何编辑后错误的可能性都会显着增加。

然后分解出常见的测试 - 例如,前四个可以进入选择案例,一旦完成,不需要为每个继承值重复。

这是一个开始(只是一个骷髅,因为对我来说太多了,不能把它全部考虑到核心集)

Option Explicit '<<<< always use this at the tp of your modules

Sub Tester()
Dim iCase As Long
Dim iLastName As Long
Dim iFirstName As Long
Dim iMedicalRecord As Long
Dim iGender As Long
Dim iPanel As Long
Dim iInheritance As Long
Dim iFuncrefGene As Long
Dim iExonicFuncrefGene As Long
Dim iPopFreqMax As Long
Dim iClinVar As Long
Dim iCommon As Long
Dim iClassification As Long

Dim vCase, vLastName, vFirstName, vMedicalRecord, vGender, vPanel, vInheritance
Dim vFuncrefGene, vExonicFuncrefGene, vPopFreqMax, vClinVar, vCommon, vClassification
Dim iRow As Long
Dim i As Long, rw As Range, rData As Range

Application.ScreenUpdating = False
'set the range
Set rData = Worksheets("annovar").Cells(4, 1).CurrentRegion

Set rw = rData.Rows(1)
'search row and define criteria
With Application.WorksheetFunction
    iCase = .Match("Case", rData.Rows(1))
    iLastName = .Match("Last Name", rData.Rows(1), 0)
    iFirstName = .Match("First Name", rData.Rows(1), 0)
    iMedicalRecord = .Match("Medical Record", rData.Rows(1), 0)
    iGender = .Match("Gender", rData.Rows(1), 0)
    iPanel = .Match("Panel", rData.Rows(1), 0)
    iInheritance = .Match("Inheritance", rData.Rows(4), 0)
    iPopFreqMax = .Match("PopFreqMax", rData.Rows(4), 0)
    iClinVar = .Match("ClinVar", rData.Rows(4), 0)
    iCommon = .Match("Common", rData.Rows(4), 0)
    iFuncrefGene = .Match("Func.refGene", rData.Rows(4), 0)
    iExonicFuncrefGene = .Match("ExonicFunc.refGene", rData.Rows(4), 0)
    iClassification = .Match("Classification", rData.Rows(4), 0)
End With

' AD
 For iRow = 2 To rData.Rows.Count 'Start at line #2 to ignore the header row

    Set rw = rData.Rows(iRow)

    vCase = rw(iCase).Value
    vLastName = rw(iLastName).Value
    vFirstName = rw(iFirstName).Value
    vMedicalRecord = rw(iMedicalRecord).Value
    vGender = rw(iGender).Value
    vPanel = rw(iPanel).Value
    vInheritance = rw(iInheritance).Value
    vPopFreqMax = rw(iPopFreqMax).Value
    vClinVar = rw(iClinVar).Value
    vCommon = rw(iCommon).Value
    vFuncrefGene = rw(iFuncrefGene).Value
    vExonicFuncrefGene = rw(iExonicFuncrefGene).Value
    vClassification = ""

    'pathogenic
    Select Case vClinVar
        Case "pathogenic"
            vClassification = "pathogenic"
        Case "non-pathogenic"
            vClassification = "benign"
        Case "unknown"
            vClassification = "VUS"
        Case "untested"
            vClassification = "not provided"
    End Select

    If vInheritance = "XL" Then vClassification = "unknown"

    If vClassification = "" And vClinVar = "" Then

        If vInheritance = "AD" Then
            'do AD tests

        End If

        If vInheritance = "AR" Then
            'do AR tests

        End If

        'etc etc

    End If

    'finally, populate the classification value (if any was allocated)
    rw(iClassification).Value = vClassification

  Next iRow

End Sub