Search This Blog

Tuesday, 7 August 2012

MOVING TITLE FOR USERFORM


Click on the video to see how it will look like.

video

Follow the below steps to create a moving title for your userform:

1. Launch Microsoft Excel
2. Press ALT+F11 to open Visual Basic Editor
3. Insert an userform
4. Put a label control on your userform ( say, label 1) and clear the text (delete the text under caption in properties)
5.Put another label (say, label 2) above label 1and write your text in label 2( I wrote "EXCEL VBA TIPS").

See the below image



6. Double click on any userform control, code window will appear.
7. Select "General" as object and paste the below code there as shown in the below image(Click to enlarge)



Code:

Private Sub MoveTitle()
    On Error Resume Next
Again:
    Label2.Left = Label2.Left - 0.11
    DoEvents
    For j = 1 To 50000: Next
    If Label2.Left + Label2.Width < 0 Then Label2.Left = Me.Width
    GoTo Again

8. Now select "Userform" as object and "Activate" as procedure and paste the below code there as shown in below image.(Click to enlarge)


Code:

Private Sub UserForm_Activate()
Call MoveTitle
End Sub

Run the userform and your userform title will start moving as shown in the above video.

Did this post help you? Please post your valuable comment. Thanks!!


No comments:

Post a Comment