D
David Adamson
What I am trying to do is show a series of 6 images (Area) who's background
colour changes depending upon the value in a table (5 choices for colour).
What is happening here is that it is reading in 10 years of data and then
checking to see what that value is for the 6 images and then based on its
value it should give me the appropriate colour. I can get the background
colour to change but not correctly.
What is happening is that one the value is >0 it bails out on the second
case statement
Case 0 To choice1 ' choice1 '.Value
Results("Area" & j).BackColor = Colour2
I think this is because at Values = 20 but at choice = "20"
I'm not to sure how to get around this but I'm sure I haven't defined
something right and my brain has died
Secondly how do I delay the macro (by one or two seconds) at the Next i
stage so that you can see what happens to each image for each column of
data.
Thanks in advance
Private Sub RunALL_Click()
'Dim Year As Interger
Dim Area As Image
'Dim choice As b
Dim i, j As Integer
'set colours
Colour1 = vbWhite
Colour2 = C1.BackColor
Colour3 = c2.BackColor
Colour4 = c3.BackColor
Colour5 = vbBlack
'10 year's worth of data to evaluate
For i = 1 To 10
Year.Caption = Format("Year" & i)
For j = 1 To 6
With Worksheets("Amount")
'image value
Values = Cells(2 + j, 1 + i) '.value
End With
Select Case Values
Case 0
Results("Area" & j).BackColor = Colour1
Case 0 To choice1 ' choice1 '.Value
Results("Area" & j).BackColor = Colour2
Case choice1 To choice2
Results("Area" & j).BackColor = Colour3
Case choice2 To choice3
Results("Area" & j).BackColor = Colour4
Case Is > choice3
Results("Area" & j).BackColor = Colour5
End Select
Next j
DoEvents
Next i
End Sub
colour changes depending upon the value in a table (5 choices for colour).
What is happening here is that it is reading in 10 years of data and then
checking to see what that value is for the 6 images and then based on its
value it should give me the appropriate colour. I can get the background
colour to change but not correctly.
What is happening is that one the value is >0 it bails out on the second
case statement
Case 0 To choice1 ' choice1 '.Value
Results("Area" & j).BackColor = Colour2
I think this is because at Values = 20 but at choice = "20"
I'm not to sure how to get around this but I'm sure I haven't defined
something right and my brain has died
Secondly how do I delay the macro (by one or two seconds) at the Next i
stage so that you can see what happens to each image for each column of
data.
Thanks in advance
Private Sub RunALL_Click()
'Dim Year As Interger
Dim Area As Image
'Dim choice As b
Dim i, j As Integer
'set colours
Colour1 = vbWhite
Colour2 = C1.BackColor
Colour3 = c2.BackColor
Colour4 = c3.BackColor
Colour5 = vbBlack
'10 year's worth of data to evaluate
For i = 1 To 10
Year.Caption = Format("Year" & i)
For j = 1 To 6
With Worksheets("Amount")
'image value
Values = Cells(2 + j, 1 + i) '.value
End With
Select Case Values
Case 0
Results("Area" & j).BackColor = Colour1
Case 0 To choice1 ' choice1 '.Value
Results("Area" & j).BackColor = Colour2
Case choice1 To choice2
Results("Area" & j).BackColor = Colour3
Case choice2 To choice3
Results("Area" & j).BackColor = Colour4
Case Is > choice3
Results("Area" & j).BackColor = Colour5
End Select
Next j
DoEvents
Next i
End Sub