Hello All,
I need to insert a piece of coding in an existing code and I am totally new to VBA. here is the original code :
Public Sub ActualServiceLevelAchieved()
Dim rngActualRequestDate As Range
Dim rngRequestDate As Range
Dim dtmDelivery As Date
Dim dtmRequestDate As Date
Dim lngSLA As Long
For Each rngActualRequestDate In Sheets("DATA").Range(Sheets("DATA").Range("A2"), _
Sheets("DATA").Range("A1048576").End(xlUp))
lngSLA = Intersect(rngActualRequestDate.EntireRow, Range("B1").EntireColumn)
If Len(rngActualRequestDate) > 0 And lngSLA > 0 Then
dtmDelivery = rngActualRequestDate
dtmDelivery = AddBusinessDay(dtmDelivery, lngSLA, Intersect(rngActualRequestDate.EntireRow, Sheets("DATA").Range("State").EntireColumn))
dtmRequestDate = Intersect(rngActualRequestDate.EntireRow, Range("R1").EntireColumn)
'If weekend or weekday > 3pm.
If Weekday(dtmRequestDate, vbMonday) >= 6 Or CDbl(TimeValue(dtmRequestDate)) >= 0.625 Then
Else: dtmDelivery = CStr(Format(dtmDelivery, "d/mm/yyyy")) & " 17:00"
End If
'Populate date.
Intersect(rngActualRequestDate.EntireRow, Sheets("DATA").Range("ActualServiceLevelAchieved").EntireColumn) = dtmDelivery
End If
Next rngActualRequestDate
End Sub
What I want to do is to add a condition in the section : 'If weekend or weekday > 3pm.
I have a new column (column O) with 4 types of values possible : FULL, RESTRICTED, DESKTOP and RURAL.
what if want to do is : IF the value in Column O is FULL, RESTRICTED or RURAL then the part of the code :
'If weekend or weekday > 3pm.
If Weekday(dtmRequestDate, vbMonday) >= 6 Or CDbl(TimeValue(dtmRequestDate)) >= 0.625 Then
Else: dtmDelivery = CStr(Format(dtmDelivery, "d/mm/yyyy")) & " 17:00"
End If
Is to be applied. If the cell in column O is = DESKTOP, then this coding is not to be applied.
I don't know if it makes sense to you or not. Please let me know if you you need more info.
Thanks.
Bookmarks