Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Case Statement error

Thanks mudraker problems solved

I juist wasn't thinking about Dim was I?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Case Statement jlclyde Excel Discussion (Misc queries) 3 December 4th 08 05:04 PM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
Anyone actually get Case statement to work ... ? ForestFeeder Excel Worksheet Functions 3 April 21st 06 04:14 PM
Case Statement Help stck2mlon Excel Programming 3 June 2nd 04 01:44 PM
Case statement smi Excel Programming 2 October 18th 03 02:20 PM


All times are GMT +1. The time now is 05:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"