mercredi 8 mars 2017

VBA - IF statements with AND not working

Any help would be great. I cant seem to get the ELSEIF with the AND to work.

I am using a user-form. When they press the button the user form appears with check boxes. I am having trouble when both check boxes are checked. individually they work fine,

I am not sure what i am doing wrong. any help would be greatly appreciated

If Intact.Value = True Then
    storDate = Sheets("escalation").Cells(Selection.Row, 2)
    storProject = Sheets("escalation").Cells(Selection.Row, 3)
    StorBill = Sheets("escalation").Cells(Selection.Row, 4)
    storIntact = "Intact"

    With objWord.ActiveDocument
    .formfields("text2").Result = storDate
    .formfields("Text3").Result = storProject
    .formfields("Text4").Result = StorBill
    .formfields("Text9").Result = storIntact
    End With

ElseIf Compugen.Value = True Then
    storDate = Sheets("escalation").Cells(Selection.Row, 2)
    storProject = Sheets("escalation").Cells(Selection.Row, 3)
    StorBill = Sheets("escalation").Cells(Selection.Row, 4)
    storCompugen = "Compugen"

    With objWord.ActiveDocument
    .formfields("text2").Result = storDate
    .formfields("Text3").Result = storProject
    .formfields("Text4").Result = StorBill
    .formfields("Text9").Result = storCompugen
    End With

ElseIf Intact.Value And Compugen.Value = True Then
    storDate = Sheets("escalation").Cells(Selection.Row, 2)
    storProject = Sheets("escalation").Cells(Selection.Row, 3)
    StorBill = Sheets("escalation").Cells(Selection.Row, 4)
    storIntact = "Intact"
    storDate1 = Sheets("escalation").Cells(Selection.Row, 2)
    storProject1 = Sheets("escalation").Cells(Selection.Row, 3)
    StorBill1 = Sheets("escalation").Cells(Selection.Row, 4)
    storCompugen = "Compugen"

    With objWord.ActiveDocument
    .formfields("text2").Result = storDate
    .formfields("Text3").Result = storProject
    .formfields("Text4").Result = StorBill
    .formfields("Text9").Result = storIntact
    .formfields("text5").Result = storDate1
    .formfields("Text6").Result = storProject1
    .formfields("Text7").Result = StorBill1
    .formfields("Text8").Result = storCompugen
    End With
End If

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire