mercredi 27 novembre 2019

VBA IF Statements converted to Case

Hi this one of the first times I am using the case statement and it would be really helpful for someone to convert.

I had a more simplistic If statement that was working but unable to have this work likely due to my end if/else placements. Always appreciate the help!

Public SLA As Range
Public Data1, Data5 As Range
Public TotalT As Range

Set Data1 = Worksheets("Log").Range("N" & ActiveCell.Row)
Set Data5 = Worksheets("Log").Range("R" & ActiveCell.Row)
Set TotalT = Worksheets("Log").Range("L" & ActiveCell.Row)
Set SLA = Worksheets("Log").Range("M" & ActiveCell.Row)



If Data1 <> "" Then
    If Data5 = "A" Or "B" Then
        If TotalT.Value <= 5 And TotalT.Value <> "" Then
            SLA.Value = "Yes"
        Else
            If TotalT.Value = 0 Then
            Else
                SLA.Value = TotalT - 5

            End If
        End If
    End If
End If

If Data1 <> "" Then
    If Data5 = "C" Or "D" Then
        If TotalT.Value <= 1 And TotalT.Value <> "" Then
            SLA.Value = "Yes"
        Else
            If TotalT.Value = 0 Then
            Else
                SLA.Value = TotalT - 1
            End If
        End If
    End If
End If

If Data1 <> "" Then
    If Data5 = "E" Or "F" Or "G" Or "H" Or "I" Or "J" Then
        If TotalT.Value <= 10 And TotalT.Value <> "" Then
            SLA.Value = "Yes"
        Else
            If TotalT.Value = 0 Then
            Else
                SLA.Value = TotalT - 10
            End If
        End If
    Else
    End If
End If

Aucun commentaire:

Enregistrer un commentaire