Consulting

Results 1 to 2 of 2

Thread: help with VBA to classify and highlight row based on value of cell

  1. #1
    VBAX Regular
    Joined
    May 2014
    Posts
    71
    Location

    help with VBA to classify and highlight row based on value of cell

    I am trying to write a multi-step code that will classify based on criteria and highlight a row. The code is below is a small section and it runs, but does not give the desired results that are in column K of the attached spreadsheet. Thanks.

    For example,

    If ClinVar = "unknown" Then the Classification = "uncertain significance" and that row is highlighted yellow.

    [CODE]

    'Find columns
    Cells.Find("Gender", , xlValues, xlWhole).EntireColumn.SpecialCells(xlCellTypeConstants).Select
    Cells.Find("Name", , xlValues, xlWhole).EntireColumn.SpecialCells(xlCellTypeConstants).Select
    Cells.Find("Inheritence", , xlValues, xlWhole).EntireColumn.SpecialCells(xlCellTypeConstants).Select
    Cells.Find("PopFreqMax", , xlValues, xlWhole).EntireColumn.SpecialCells(xlCellTypeConstants).Select
    Cells.Find("ClinVar", , xlValues, xlWhole).EntireColumn.SpecialCells(xlCellTypeConstants).Select
    Cells.Find("Common", , xlValues, xlWhole).EntireColumn.SpecialCells(xlCellTypeConstants).Select
    Cells.Find("Classification", , xlValues, xlWhole).EntireColumn.SpecialCells(xlCellTypeConstants).Select

    Dim sh1 As Worksheet
    ' create short references to sheets
    ' inside the Sheets() use either the tab number or name
    Set sh1 = Sheets("annovar")


    'STEP 2 - check ClinVar
    If Inheritence = "autosomal dominant" And PopFreqMax >= 0.01 And Clinvar = "benign" Then Classification = "benign"
    If Classification = "benign" Then rC.Interior.ColorIndex = 5 'Blue
    If Inheritence = "autosomal dominant" And PopFreqMax >= 0.01 And Clinvar = "probable-benign" Then Classification = "likely benign"
    If Classification = "likely benign" Then rC.Interior.ColorIndex = 8 'Cyan
    If Inheritence = "autosomal dominant" And PopFreqMax >= 0.01 And Clinvar = "unknown" Then Classification = "uncertain significance"
    If Classification = "uncertain significance" Then rC.Interior.ColorIndex = 6 'Yellow
    If Inheritance = "autosomal dominant" And PopFreqMax >= 0.01 And Clinvar = "untested" Then Classification = "not provided"
    If Classification = "not provided" Then rC.Interior.ColorIndex = 21 'Purple
    If Inheritance = "autosomal dominant" And PopFreqMax >= 0.01 And Clinvar = "probable-pathogenic" Then Classification = "likely pathogenic"
    If Classification = "likely pathogenic" Then rC.Interior.ColorIndex = 7 'Magenta
    If Inheritance = "autosomal dominant" And PopFreqMax >= 0.01 And Clinvar = "pathogenic" Then Classification = "pathogenic"
    If Classification = "pathogenic" Then rC.Interior.ColorIndex = 9 'Dark Red

  2. #2
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    ---------- deleted
    Last edited by patel; 05-01-2014 at 11:36 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •