(Solved) – How to Find working Hour in Time Range using VBA

  • by
(solved)-–-how-to-find-working-hour-in-time-range-using-vba

hi i used to make a formula in excel with finding the formula and it works with the below code:

=IF(AND(ISNUMBER($C7),ISNUMBER($F7),ISNUMBER($G7),IF($F7<$G7,AND(R$5>=TIME(HOUR($F7),0,0),R$5<=$G7),OR(R$5>=TIME(HOUR($F7),0,0),R$5<=$G7))),1,FALSE)

when i convert to vba. i dont know what am i missing.

                        If IsDate(RngData(i, 1)) = True And IsDate(GetTimeIn) = True And IsDate(GetTimeOut) = True Then
                        If GetTimeIn < GetTimeOut Then
                            If TimeValue("09:00") >= TimeValue(Hour(GetTimeIn) & ":00") And TimeValue("09:00") <= TimeValue(GetTimeOut) Then
                                li.SubItems(7) = 1
                            ElseIf TimeValue("09:00") >= TimeValue(Hour(GetTimeIn) & ":00") Or TimeValue("09:00") <= TimeValue(GetTimeOut) Then
                                li.SubItems(7) = 1
                            Else
                                li.SubItems(7) = 0
                            End If

enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *