Need Solution for Userform Macros

madhuchelliah

Board Regular
Joined
Nov 22, 2017
Messages
226
Office Version
  1. 2019
Platform
  1. Windows
Hello Guys, the code i mentioned below is my userform code. If i show userform in between of my macro the macros stopped and showing userform alone. It is not continuing to the next macros. What is the reason for macros not continuing until i unload the userform? What i am missing here?

Code:
Option Explicit

Dim Running         As Boolean

Private Sub CommandButton1_Click()  'Close

    Application.EnableEvents = True
    Unload Me
    
End Sub

Private Sub Image4_Click()

End Sub

Private Sub UserForm_Activate()

    Running = True
    Call Animation

End Sub

Private Sub Animation()

Dim x               As Integer
Dim y               As Integer
Dim MyTimer         As Double

    DoEvents
    x = 1
    y = 1
    MyTimer = Timer
    Do
        On Error Resume Next
        SplashScreen.Image3.Picture = LoadPicture _
                (ThisWorkbook.Path & "\Images\Animation\Flag\" & x & ".Gif")
        SplashScreen.Image4.Picture = LoadPicture _
                (ThisWorkbook.Path & "\Images\Animation\Pulser\" & y & ".Gif")
        On Error GoTo 0
        Do
        Loop While Timer - MyTimer < 0.07
        If x = 8 Then
            x = 1
            Else
            x = x + 1
        End If
        If y = 11 Then
            y = 1
            Else
            y = y + 1
        End If
        MyTimer = Timer
        DoEvents
    Loop While Running
   

End Sub

Private Sub UserForm_Initialize()

    Application.WindowState = xlMaximized

End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

    Running = False

End Sub
 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I think you're calling your userform Modal.. which stops execution of the calling code until the userform is terminated. Instead try this within the code that calls the userform:
Code:
UserForm1.Show False
 
Upvote 0
Try setting running = true within your initialise routine, not just the activate routine
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top