Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Case Statement error
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Case Statement error
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 -- Message posted from http://www.ExcelForum.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Case Statement error
Thanks mudraker problems solved
I juist wasn't thinking about Dim was I? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Case Statement | Excel Discussion (Misc queries) | |||
Case without Select Case error problem | Excel Discussion (Misc queries) | |||
Anyone actually get Case statement to work ... ? | Excel Worksheet Functions | |||
Case Statement Help | Excel Programming | |||
Case statement | Excel Programming |