• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Marquee in excel

vijehspaul

Member
Hi,

I am a newbee in excel. I made a excel sheet. To make it little attractive, i would like to insert a caption/message which is rolling ( marquee)

How to insert a marquee in excel ?

Am using excel 2010


All comments are appritiated.


Best,

Vijesh
 
This is not possbile directly... however you can use VBA and a USERFROM to accomplish..


Create a New Workbook

Go to Visual Basis Editor

Insert a Userform

Insert a Label Control, give the name as lblMsg


Once done...

Double click on the form to go to Code view and delete everything currently over there and then put the code below in the userform


Hit F5 and you are ready to show a running marquee...

[pre]
Code:
Dim msngSpeed As Single

Private Sub cmdExit_Click()
End
End Sub

Private Sub cmdFeedback_Click()
frmFeedback.Show
End Sub

Private Sub lblMsg_Click()

End Sub

Private Sub UserForm_Activate()
msngSpeed = 0.1
RunMarquee
End Sub

Sub RunMarquee()
'There is no timer control in VBA excel, there is a timer function that returns the number of
'seconds since midnight. Weird, but workable.

Dim sngStart As Single
Dim sngPausetime As Single

On Error Resume Next

sngStart = Timer   ' Set start time. No. of seconds since midnight

StartHere:
sngPausetime = msngSpeed
'following will pause 1 second
Do While Timer < sngStart + sngPausetime
DoEvents    ' Yield to other processes.
Loop

'Now run the marquee
Call LabelMarquee(lblMsg)

sngStart = Timer
GoTo StartHere
End Sub

Private Sub LabelMarquee(ctl As Control)
'Set what you want displayed in the Caption property of the control, make sure you have at least 1 trailing space.
Dim buffer As String
buffer = ctl.Caption
If Len(buffer) > 1 Then
ctl.Caption = Mid$(buffer, 2) & Left$(buffer, 1)
End If
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
End
End Sub
[/pre]

PS: this is not my code; and I do not remember the original coder so all the kudos go to him / her.


There is just one glitch... when the marquee starts over instead of characters running the code wait for the whole word and then displays... and I did not get the time to fix it...


HTH

~Vijay Sharma

sharma.vijay1-at-gmail.com
 
Back
Top