Case Statement error

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
 
M

mudraker

Use Pause command or Wait command

Application.Wait Now() + TimeValue("00:00:10")


sub dddd
your commands

pause

or

Application.Wait Now() + TimeValue("00:00:10")

more commands

end sub


Re Your case problem if you have not declared you variables I sugges
you do declare them and have
Option Explicit
as the very first entry on you module sheet before trying to sort ou
your proble
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Scrol window 1
Grouping Rows 4
Auto-Hide Columns 2
PHP Problem 8
vArray = Sheet2.Range("A1:A" & lr) troubles ahoy 11
Avoid multiple select constructs 2
User defined data type (losing its data) 2
VB Quiz problem 10

Top