+ Reply to Thread
Results 1 to 3 of 3

nested ifs not executing

Hybrid View

  1. #1
    Registered User
    Join Date
    03-28-2007
    Posts
    27

    nested ifs not executing

    Hey guys,
    I have several if thens that i am trying to consolidate into one sub and assign one button to it. All of them seem to work when run on their own, but only the first 2 get executed when put together.
    The code is below.
    Any ideas?
    Thanks,
    ritz
    Sub dashboardupdate()
        
    For Each cell In Range("dashboard")
        'Makes the completed cells green if they were on time
        If cell.Offset(0, 16) > cell.Offset(0, 15) Then
            cell.Offset(0, 15).Interior.ColorIndex = 4
        
        'This will make all past due cells red
            If cell.Offset(0, 16) < cell.Offset(0, 15) Then
                If IsDate(cell.Offset(0, 15)) Then
                    cell.Offset(0, 15).Interior.ColorIndex = 3
        
        'Makes the completed cells green if they are equal and they are date values
                If cell.Offset(0, 16) = cell.Offset(0, 16) Then
                    If IsDate(cell.Offset(0, 15)) Then
                        cell.Offset(0, 15).Interior.ColorIndex = 4
        
        'This will color due date of today in R with a turqoise color
                    If cell.Offset(0, 16) = Range("today") Then
                        cell.Offset(0, 16).Interior.ColorIndex = 8
        
        'This will make all of the empty cells pink if both Q and R are empty
                        If cell.Offset(0, 15) = cell.Offset(0, 16) Then
                            If cell.Offset(0, 16) = "" Then
                                cell.Offset(0, 15).Interior.ColorIndex = 38
        
        'This will make all cells containing a date in R and blank in corresponding Q dark blue
                            If IsDate(cell.Offset(0, 16)) And cell.Offset(0, 15) = "" Then
                                cell.Offset(0, 15).Interior.ColorIndex = 32
        
        'This will make all cells with NAB equal to issue manager with a QA date Complete
                                If cell.Offset(0, 5) = cell.Offset(0, 7) Then
                                    If IsDate(cell.Offset(0, 19)) Then _
                                        cell.Offset(0, 32) = "Complete"
                                    End If
                                End If
                            End If
                            End If
                        End If
                    End If
                    End If
                End If
                End If
            End If
        
    Next
    End Sub

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Ritz

    I think your end if statements are in the wrong place. Looking at the code, you are testing for a > situation. However, the next if is tested only if that occurs. There should be an endif for the > test to allow the subsequent items to be tested on their own.

    hth

    rylo

  3. #3
    Registered User
    Join Date
    03-28-2007
    Posts
    27

    Thanks Rylo

    Thanks Rylo,
    I'll give that a shot and see if it works.
    -Ritz

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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