Results 1 to 4 of 4

If condition satisfied but ignored

Threaded View

  1. #1
    Registered User
    Join Date
    07-08-2019
    Location
    perth
    MS-Off Ver
    365
    Posts
    2

    Unhappy If condition satisfied but ignored

    OK this is annoying me.
    The If condition is satisfied but jumps to the next one where the (O_Hrs + Time_Acc >8) when in fact it satisfies the (O_Hrs + Time_Acc <=8)

    What on earth am i missing.

     If (Time_Acc < 8) And (O_Hrs + Time_Acc <= 8) And (OT_Type = "New") Then
                                    MYOB_Pre_Export.Cells(X, "A").Copy MYOB_Export.Cells(Y, "A")
                                    MYOB_Pre_Export.Cells(X, "B").Copy MYOB_Export.Cells(Y, "B")
                                    MYOB_Pre_Export.Cells(X, "C").Copy MYOB_Export.Cells(Y, "C")
                                    MYOB_Pre_Export.Cells(X, "G").Copy MYOB_Export.Cells(Y, "G")
                                    If MYOB_Pre_Export.Cells(X, "G") = "A - ANNUAL LEAVE" Then 'checks if its annual leave hours
                                         MYOB_Export.Cells(Y, "D") = ".Holiday Pay Hourly"
                                    Else
                                        If MYOB_Pre_Export.Cells(X, "G") = "A - SICK LEAVE" Then 'checks if its sick leave hours
                                        MYOB_Export.Cells(Y, "D") = ".Sick Pay Hourly"
                                        Else
                                         MYOB_Export.Cells(Y, "D") = "..Base Hourly"
                                        End If
                                        End If
                                                                          
                                        If (lunch_break = 0) And (Time_Acc + O_Hrs > 5) Then 'checks to see if lunch break flag is not set and the worked time greater than 5 hours
                                        C_Hrs = (O_Hrs - 0.5) 'deducts luch break
                                        lunch_break = 1
                                        Else
                                        C_Hrs = O_Hrs 'no lunch break deducted
                                        End If
                                        MYOB_Export.Cells(Y, "F") = C_Hrs
                                        Y = Y + 1
                                        
                                    Else
                                    If (Time_Acc < 8) And (O_Hrs + Time_Acc > 8) And (O_Hrs + Time_Acc < 10) And (OT_Type = "New") Then
                                    MYOB_Pre_Export.Cells(X, "A").Copy MYOB_Export.Cells(Y, "A")
                                    MYOB_Pre_Export.Cells(X, "B").Copy MYOB_Export.Cells(Y, "B")
                                    MYOB_Pre_Export.Cells(X, "C").Copy MYOB_Export.Cells(Y, "C")
                                    MYOB_Pre_Export.Cells(X, "G").Copy MYOB_Export.Cells(Y, "G")
                                                              MYOB_Export.Cells(Y, "D") = "..Base Hourly"
                                                              
                                    If (lunch_break = 0) And (Time_Acc + O_Hrs > 5) Then 'checks to see if lunch break flag is not set and the worked time greater than 5 hours
                                    C_Hrs = ((8 - Time_Acc) - 0.5) 'deducts lunch break
                                    lunch_break = 1
                                    Else
                                    C_Hrs = (8 - Time_Acc)
                                    End If


    VBA If condition fail.png
    Last edited by remkin76; 07-08-2019 at 11:48 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 06-01-2015, 06:05 PM
  2. Extract values if condition is satisfied
    By bjnockle in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-26-2014, 08:39 AM
  3. Replies: 2
    Last Post: 08-01-2011, 03:22 PM
  4. Replies: 8
    Last Post: 05-06-2011, 08:25 AM
  5. [SOLVED] Deleting columns if condition is satisfied
    By kent-dk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2006, 06:25 AM
  6. Copy sheets only if condition is satisfied (mat)
    By matthias in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-10-2006, 01:10 PM
  7. Replies: 0
    Last Post: 01-11-2006, 07:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1