mercredi 22 avril 2015

If VBA multiple conditions

I have a problem with my vba code and instructions IF, I have to use a multi-conditionig, but vba, if I check the condition 4 as true always ignores other conditions.

((Condition 1) or (Condition 2)) and (condition 3 or condition 4)

Needs to macro accepts only the specified options:

((TRUE) or (FALSE)) and (TRUE or FALSE)

((TRUE) or (FALSE)) and (TRUE or TRUE)

((FALSE) or (TRUE)) and (TRUE or FALSE)

((FALSE) or (TRUE)) and (TRUE or TRUE)

There is real code:

If ((raport_glowny.Cells(i, R_delivedate_C).Value = Date(Arkusz6.DeliveryDaySMS)) And (raport_glowny.Cells(i, R_deliverytime_C).Value >= CDate(Arkusz6.DeliveryHourSMS.Value))) Or _
                    ((raport_glowny.Cells(i, R_delivedate_C).Value = CDate(Arkusz6.DeliveryDaySMS) + 1) And (raport_glowny.Cells(i, R_deliverytime_C).Value < CDate(Arkusz6.DeliveryHourSMS.Value))) And ((raport_glowny.Cells(i, R_deliverytime_C).Value > 0) Or (Arkusz6.cbSMSforecast = True)) _
                    Then

If anyone can help I will be very grateful

Aucun commentaire:

Enregistrer un commentaire