Search This Blog

Tuesday, 7 August 2012

MOVING TITLE FOR USERFORM


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


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.05
    DoEvents
    For j = 1 To 50000: Next
    If Label2.Left + Label2.Width < 0 Then Label2.Left = Me.Width
    GoTo Again
End Sub

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!!


13 comments:

  1. Hi Shweta,

    Mind blowing technique but i have a question i hope you will help me in the same i want to do the same thing in worksheet rather than userform what i have to do??

    ReplyDelete
  2. very very useful sir, Thank you very much sir. It is amazing.

    ReplyDelete
  3. after making the running text in excel VBA user form, but i can not edit in those excel file.

    ReplyDelete
  4. Very helpful. Simple and effective method. Thanks a lot.

    ReplyDelete
  5. Thanks for your teaching so easily. Very helpful

    ReplyDelete
  6. how can i do it to move to the right?

    ReplyDelete
  7. so helpfull project thanks a lot

    ReplyDelete