Hi,
I urgently need help with a problem I have. I have a button on an excel worksheet that opens a userform, reads an excel file row by row until the last row of data and based on the values in the cells will display an image. This is to create an animation effect. The program is working fine, however the problem I have is that I have tried to put a timer in to slow down the animation but it is just not working and I don't know why. When I run the animation it goes so fast through each row there is no time to see the images. The only way I can ensure that it is working is if I put breakpoints at each case which shows me it is actually working.
I would also like to stop the "loop" when it gets to the last row instead of just going through all the rows and then starting again. The code for the program is below:
Private Sub UserForm_Activate()
Running = True
Call Animation
End Sub
Private Sub Animation()
Dim MyTimer As Double
Dim i As Long
DoEvents
MyTimer = Timer
Do
Do
Loop While Timer - MyTimer < 1
For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
Sheets("Sheet1").Select
Sheets("Sheet1").Cells(i, 1).Select
'***Case 1
If Worksheets("Sheet1").Cells(i, 2).Value = "1" And Cells(i, 3).Value = "1" Then SplashScreen.Image3.Picture = LoadPicture _
(ThisWorkbook.Path & "\Images\Animation\Ship\1.Gif")
''***Case 2
If Worksheets("Sheet1").Cells(i, 2).Value = "1" And Cells(i, 3) = Empty Then SplashScreen.Image3.Picture = LoadPicture _
(ThisWorkbook.Path & "\Images\Animation\Ship\2.Gif")
'
''***Case 3
If Worksheets("Sheet1").Cells(i, 2) = Empty And Cells(i, 3).Value = "1" Then SplashScreen.Image3.Picture = LoadPicture _
(ThisWorkbook.Path & "\Images\Animation\Ship\3.Gif")
'
''***Case 4
If Worksheets("Sheet1").Cells(i, 2) = Empty And Cells(i, 3) = Empty Then SplashScreen.Image3.Picture = LoadPicture _
(ThisWorkbook.Path & "\Images\Animation\Ship\4.Gif")
Next i
MyTimer = Timer
DoEvents
Loop While Running
End Sub
Bookmarks