nepotist
04-22-2009, 01:07 PM
Here is a part of my code
Dim Fcolor As Double
Dim Scolor As Double
Dim Tcolor As Double
Dim Ftcolor As Double
Worksheets("WPC").Activate
With ActiveSheet
Fcolor = Cells(71, 5).Interior.ColorIndex
Scolor = Cells(72, 5).Interior.ColorIndex
Tcolor = Cells(73, 5).Interior.ColorIndex
Ftcolor = Cells(74, 5).Interior.ColorIndex
End With
Worksheets("Report").Activate
For u = u To 3 Step -1
Ypde = Cells(u, "C").Value
Ype = Cells(u, "d").Value
Yrow = Cells(u, "E").Value
Ycon = Cells(u, "F").Value
If Ypde >= P0Y1 And Ypde <= P0Y2 Then
Cells(u, "s").Interior.ColorIndex = Fcolor
Cells(u, "aa").Interior.ColorIndex = Fcolor
ElseIf Ypde >= P1Y1 And Ypde <= P1Y2 Then
Cells(u, "s").Interior.ColorIndex = Scolor
Cells(u, "aa").Interior.ColorIndex = Scolor
ElseIf Ypde >= P2Y1 And Ypde <= P2Y2 Then
Cells(u, "s").Interior.ColorIndex = Tcolor
Cells(u, "aa").Interior.ColorIndex = Tcolor
ElseIf Ypde >= P3Y1 And Ypde <= P3Y2 Then
Cells(u, "s").Interior.ColorIndex = Ftcolor
Cells(u, "aa").Interior.ColorIndex = Ftcolor
End If
If Ype >= P0Y1 And Ype <= P0Y2 Then
Cells(u, "t").Interior.ColorIndex = Fcolor
Cells(u, "ab").Interior.ColorIndex = Fcolor
ElseIf Ype >= P1Y1 And Ype <= P1Y2 Then
Cells(u, "t").Interior.ColorIndex = Scolor
Cells(u, "AB").Interior.ColorIndex = Scolor
ElseIf Ype >= P2Y1 And Ype <= P2Y2 Then
Cells(u, "T").Interior.ColorIndex = Tcolor
Cells(u, "AB").Interior.ColorIndex = Tcolor
ElseIf Ype >= P3Y1 And Ype <= P3Y2 Then
Cells(u, "T").Interior.ColorIndex = Ftcolor
Cells(u, "AB").Interior.ColorIndex = Ftcolor
End If
If Yrow >= P0Y1 And Yrow <= P0Y2 Then
Cells(u, "U").Interior.ColorIndex = Fcolor
Cells(u, "aC").Interior.ColorIndex = Fcolor
ElseIf Yrow >= P1Y1 And Yrow <= P1Y2 Then
Cells(u, "U").Interior.ColorIndex = Scolor
Cells(u, "aC").Interior.ColorIndex = Scolor
ElseIf Yrow >= P2Y1 And Yrow <= P2Y2 Then
Cells(u, "U").Interior.ColorIndex = Tcolor
Cells(u, "aC").Interior.ColorIndex = Tcolor
ElseIf Yrow >= P3Y1 And Yrow <= P3Y2 Then
Cells(u, "U").Interior.ColorIndex = Ftcolor
Cells(u, "AC").Interior.ColorIndex = Ftcolor
End If
If Ycon >= P0Y1 And Ycon <= P0Y2 Then
Cells(u, "V").Interior.ColorIndex = Fcolor
Cells(u, "aD").Interior.ColorIndex = Fcolor
ElseIf Ycon >= P1Y1 And Ycon <= P1Y2 Then
Cells(u, "V").Interior.ColorIndex = Scolor
Cells(u, "AD").Interior.ColorIndex = Scolor
ElseIf Ycon >= P2Y1 And Ycon <= P2Y2 Then
Cells(u, "V").Interior.ColorIndex = Tcolor
Cells(u, "aD").Interior.ColorIndex = Tcolor
ElseIf Ycon >= P3Y1 And Ycon <= P3Y2 Then
Cells(u, "V").Interior.ColorIndex = Ftcolor
Cells(u, "aD").Interior.ColorIndex = Ftcolor
End If
Dim yr As Integer
yr = Cells(u, i + 2).Value
If yr >= P0Y1 And yr <= P0Y2 Then
Range(Cells(u, "A"), Cells(u, "R")).Interior.ColorIndex = Fcolor
ElseIf yr >= P1Y1 And yr <= P1Y2 Then
Range(Cells(u, "A"), Cells(u, "R")).Interior.ColorIndex = Scolor
ElseIf yr >= P2Y1 And yr <= P2Y2 Then
Range(Cells(u, "A"), Cells(u, "R")).Interior.ColorIndex = Tcolor
ElseIf yr And r <= P3Y2 Then
Range(Cells(u, "A"), Cells(u, "R")).Interior.ColorIndex = Ftcolor
End If
Next u
My probelm here is the code is fine when I run the function it dosent give me errors.
If you look at the Fcolor, scolor.. variable they are the colorindex in other spread sheet that user selects. when I click my command button the re-run of the application dosent take the latest colors select by the user, but when I apply the break point at those variable and run the rest of the function using f8 it works perfectly.. I got no clue why it is happening >??
Dim Fcolor As Double
Dim Scolor As Double
Dim Tcolor As Double
Dim Ftcolor As Double
Worksheets("WPC").Activate
With ActiveSheet
Fcolor = Cells(71, 5).Interior.ColorIndex
Scolor = Cells(72, 5).Interior.ColorIndex
Tcolor = Cells(73, 5).Interior.ColorIndex
Ftcolor = Cells(74, 5).Interior.ColorIndex
End With
Worksheets("Report").Activate
For u = u To 3 Step -1
Ypde = Cells(u, "C").Value
Ype = Cells(u, "d").Value
Yrow = Cells(u, "E").Value
Ycon = Cells(u, "F").Value
If Ypde >= P0Y1 And Ypde <= P0Y2 Then
Cells(u, "s").Interior.ColorIndex = Fcolor
Cells(u, "aa").Interior.ColorIndex = Fcolor
ElseIf Ypde >= P1Y1 And Ypde <= P1Y2 Then
Cells(u, "s").Interior.ColorIndex = Scolor
Cells(u, "aa").Interior.ColorIndex = Scolor
ElseIf Ypde >= P2Y1 And Ypde <= P2Y2 Then
Cells(u, "s").Interior.ColorIndex = Tcolor
Cells(u, "aa").Interior.ColorIndex = Tcolor
ElseIf Ypde >= P3Y1 And Ypde <= P3Y2 Then
Cells(u, "s").Interior.ColorIndex = Ftcolor
Cells(u, "aa").Interior.ColorIndex = Ftcolor
End If
If Ype >= P0Y1 And Ype <= P0Y2 Then
Cells(u, "t").Interior.ColorIndex = Fcolor
Cells(u, "ab").Interior.ColorIndex = Fcolor
ElseIf Ype >= P1Y1 And Ype <= P1Y2 Then
Cells(u, "t").Interior.ColorIndex = Scolor
Cells(u, "AB").Interior.ColorIndex = Scolor
ElseIf Ype >= P2Y1 And Ype <= P2Y2 Then
Cells(u, "T").Interior.ColorIndex = Tcolor
Cells(u, "AB").Interior.ColorIndex = Tcolor
ElseIf Ype >= P3Y1 And Ype <= P3Y2 Then
Cells(u, "T").Interior.ColorIndex = Ftcolor
Cells(u, "AB").Interior.ColorIndex = Ftcolor
End If
If Yrow >= P0Y1 And Yrow <= P0Y2 Then
Cells(u, "U").Interior.ColorIndex = Fcolor
Cells(u, "aC").Interior.ColorIndex = Fcolor
ElseIf Yrow >= P1Y1 And Yrow <= P1Y2 Then
Cells(u, "U").Interior.ColorIndex = Scolor
Cells(u, "aC").Interior.ColorIndex = Scolor
ElseIf Yrow >= P2Y1 And Yrow <= P2Y2 Then
Cells(u, "U").Interior.ColorIndex = Tcolor
Cells(u, "aC").Interior.ColorIndex = Tcolor
ElseIf Yrow >= P3Y1 And Yrow <= P3Y2 Then
Cells(u, "U").Interior.ColorIndex = Ftcolor
Cells(u, "AC").Interior.ColorIndex = Ftcolor
End If
If Ycon >= P0Y1 And Ycon <= P0Y2 Then
Cells(u, "V").Interior.ColorIndex = Fcolor
Cells(u, "aD").Interior.ColorIndex = Fcolor
ElseIf Ycon >= P1Y1 And Ycon <= P1Y2 Then
Cells(u, "V").Interior.ColorIndex = Scolor
Cells(u, "AD").Interior.ColorIndex = Scolor
ElseIf Ycon >= P2Y1 And Ycon <= P2Y2 Then
Cells(u, "V").Interior.ColorIndex = Tcolor
Cells(u, "aD").Interior.ColorIndex = Tcolor
ElseIf Ycon >= P3Y1 And Ycon <= P3Y2 Then
Cells(u, "V").Interior.ColorIndex = Ftcolor
Cells(u, "aD").Interior.ColorIndex = Ftcolor
End If
Dim yr As Integer
yr = Cells(u, i + 2).Value
If yr >= P0Y1 And yr <= P0Y2 Then
Range(Cells(u, "A"), Cells(u, "R")).Interior.ColorIndex = Fcolor
ElseIf yr >= P1Y1 And yr <= P1Y2 Then
Range(Cells(u, "A"), Cells(u, "R")).Interior.ColorIndex = Scolor
ElseIf yr >= P2Y1 And yr <= P2Y2 Then
Range(Cells(u, "A"), Cells(u, "R")).Interior.ColorIndex = Tcolor
ElseIf yr And r <= P3Y2 Then
Range(Cells(u, "A"), Cells(u, "R")).Interior.ColorIndex = Ftcolor
End If
Next u
My probelm here is the code is fine when I run the function it dosent give me errors.
If you look at the Fcolor, scolor.. variable they are the colorindex in other spread sheet that user selects. when I click my command button the re-run of the application dosent take the latest colors select by the user, but when I apply the break point at those variable and run the rest of the function using f8 it works perfectly.. I got no clue why it is happening >??